P.3.1 - can I get more explanation about lower/upper bound?

def phase_window(probs, estimation_wires):
    """ Given an array of probabilities, return the phase window of the unitary's eigenvalue
    
    Args: 
        probs (array[float]): Probabilities on the estimation wires.
        estimation_wires (list[int]): List of estimation wires
    
    Returns:
        (float, float): the lower and upper bound of the phase
    """
    ##################
    # YOUR CODE HERE #
    ################## 
    bound_1 = 0 # MOST LIKELY OUTCOME
    bound_2 = 0 # SECOND MOST LIKELY OUTCOME
    return (bound_1, bound_2)

The question gives probability of phase estimation from implemented QPE algorithm, and the goal of the problem is get lowest and highest bound of “phase window”.

so, my approach was finding index of two indices with the highest and second highest probabillities, and divided with (2^(number of estimation wires) as following code snippet, but it gaves incorrect answer.

    id_1 = np.argmax(probs)
    bound_1 = fractional_binary_to_decimal(id_1, estimation_wires)  # MOST LIKELY OUTCOME
    prob_1  = probs[id_1]
    probs[id_1] = 0.0 #temporarily removes probability to get index with second highest probability
    
    id_2 = np.argmax(probs)
    bound_2 = fractional_binary_to_decimal(id_2, estimation_wires) #SECOND LIKELY OUTCOME
    prob_2  = probs[id_2]
    probs[id_1] = prob_1
    return(bound_1, bound_2)

result: Incorrect: the estimate window are incorrect.

If you don’t mind, can I get more hints (or definition of phase window, or something that I missed)

Thanks for reading this topic!

2 Likes

Hi @Sangwoo_Park, I think you might have run into a bug. If you interchange bound 1 and bound 2 it should work. The description of the most likely and second most likely outcome seem to be reversed.

Please let me know if this works for you!

2 Likes

That worked! Thanks!
p.s)
I think P.3.2 has a typo in the explanation of the desired output.

Current:
“”"
Returns:
[(float, float)]: a list of phase windows for 1 to 9
estimation wires
“”"

Fixed:
“”"
Returns:
[(float, float)]: a list of phase windows for “2” to 9
estimation wires
“”"

Thank you @Sangwoo_Park!

I will create an issue on the Codebook’s GitHub repo.

If you run into bugs in the future feel free to add them as issues there too!

1 Like

I’m having issues with P.3.2 and I wonder if it’s related to the issue of the order of the return value. Here’s my solution and plot. Please let me know if I’m doing something wrong, or if there’s a bug and I should move on. Thanks!

for n_wires in range(1,9):
        probs = qpe(unitary, range(n_wires), target_wires)
        bounds = phase_window(probs, range(n_wires))
        estimates.append( (np.min(bounds), np.max(bounds)) )

59%20PM

Hi @Adam_Cox, welcome to the forum!

There is a bug but it’s not the reversed order bug. The bug is the one which Sangwoo pointed out where, instead of using range(1,9) the grader expects range(2,10).

Given this, you should use estimates.append(bounds) instead of the min-max option you had, as well as changing the range.

We’re working on fixing these bugs.

Please let us know in case you find any others!

Oh my word! I’m so glad to find this forum and question! I’ve been going a little insane trying to figure out what I could possibly be doing wrong! Thank you for posting this question, and thanks @CatalinaAlbornoz for the reply & posted github issue. :pray:

1 Like