# Random Initial state for julia version?

I am trying to find the ground state for a 2D Heisenberg hamiltonian. I want to use different initial states. I read the answers/ discussions regarding the same.

How can I build the random state on X basis? ( maybe using Hadamard as mentioned in other discussions) for the Julia version?

commented by (10.7k points)
You can use the randomMPS to build a random MPS (https://itensor.github.io/ITensors.jl/stable/MPSandMPO.html#ITensors.randomMPS-Tuple{Array{#s77,1}%20where%20#s77%3C:Index,Any} ). You can see how it is used here: https://github.com/ITensor/ITensors.jl/blob/master/examples/dmrg/1d_heisenberg_conserve_spin.jl#L27

If you don't specify a desired bond dimension, it simply creates a product state with randomized elements. If you specify a desired bond dimensions, it uses a random unitary circuit applied to the specified starting state.

I'm not quite sure what you mean by a random state in the X basis, if you are looking for something more specific let us know.
commented by (10.7k points)
Oh, I guess you might mean that you were interested in performing projective measurements in the X basis to obtain random bit strings. To do that, you can apply Hadamard gates and then use the sample! function. You can see examples of applying gates here: https://github.com/ITensor/ITensors.jl/blob/master/examples/gate_evolution/quantum_simulator.jl and the sample! function here: https://itensor.github.io/ITensors.jl/stable/MPSandMPO.html#ITensors.sample!-Tuple{MPS}