for index, prob in enumerate(probs):
if np.isclose(prob,1,rtol=1e-05):
bit_list = [int(x) for x in np.binary_repr(1, width=len(estimation_wires))]
print(f"{bit_list= }")
break
phase= 0.0
t=1.0
for num in bit_list:
phase+= float(num)/2**t
#print(float(num)/2**t)
t+=1
return phase
U = qml.T.compute_matrix()
probs = qpe(U)
estimated_phase = estimate_phase(probs)
print(estimated_phase)
…
Despite I have the correct phase state output |theta> = |001> and the estimated phase of 0.125 the autograder pop up: “Incorrect: the phase calculated is not correct.”
What did I still missing?
np.argmax returns the indices of the maximum values in probs. len(estimation_wires) (n) is the number of estimation wires and it determines the precision to which we learn the phase.
So what we’re doing is finding the index of the largest value in the probability distribution and dividing that number by 2^n. This number will be an estimate of θ with an error that decreases exponentially with the number of estimation wires n.
The right hand side of node P.2 in the Codebook may be helpful, especially the first 2-3 exercises.
Please let me know if this helps to clarify your question.