Hi all,
I was going through this example code in the itensor documentation for extacting out the MPS elements.
N = 10
s = siteinds(2,N)
chi = 4
psi = random_mps(s;linkdims=chi)
# Make an array of integers of the element we
# want to obtain
el = [1,2,1,1,2,1,2,2,2,1]
V = ITensor(1.)
for j=1:N
V *= (psi[j]*state(s[j],el[j]))
end
v = scalar(V)
# v is the element we wanted to obtain:
@show v
If the MPS had a quantum number description added to it, would it suffice to adjust the line in the for loop to
V *= (psi[j] * dag(state(s[j],el[j])))
My aim is to replace the psi by some time-evolved state and to extract out the probabilities of certain bit-string configurations. I was wondering if I am doing this correctly.
Thanks a lot!
1 Like
That looks right, though I didnāt try it, try it out and see.
1 Like
This seems to work. That brings me to a follow-up on this. As I mentioned in the OP, I wanted to use this to extract the probabilities for some Z-like measurements done in a custom Hilbert space. My workflow is as follows:
- I use sample() to obtain the configurations from a time-evolved MPS.
- I feed back this information into the above function and get back the probabilities.
The problem Iām running into is that this probability is of the order 10^{-24}, essentially zero. This seems weird since the sample function seems to āworkā without throwing any errors.
I cross-checked this with another method. Instead of using this āclampingā method, I create an explicit MPS from the configurations and take its inner product with the time-evolved MPS. This also turns out to be of the order 10^{-24} and matches what I got from the clamping method (Iām not sure if āmatchesā is the right term to use, since these are extremely small numbers).
I suspect this is due to the system size being very large (N = 128), which makes probabilities exponentially small. So, how reliable is this sampling, given that the numbers are very small and there may be precision issues?
Maybe itās better to implement incomplete sampling (as described here: https://arxiv.org/pdf/1201.3974 Sec V) to ensure accurate results?
Any help in understanding this is appreciated. TIA!