2
$\begingroup$

Suppose I run the Qiskit's QAOA algorithm.

qaoa = QAOA(operator=qubit_operator, p=p, optimizer=optimizer)
result = qaoa.run(quantum_instance)

There is a built-in method that gets me the most likely binary solution for this problem. sample_most_likely(result['eigenstate']) But how do I get the whole probability distribution of binary solutions? Ultimately, I would like to calculate the expected value for my problem, not the value based solely on the most likely string.

$\endgroup$

1 Answer 1

2
$\begingroup$

You should be able to use: result['eigenstate']

That should spit out something like (if you are using 4 qubits):

{'0001': 27,
 '0010': 20,
 '0011': 1821,
 '0100': 25,
 '0101': 591,
 '0110': 46,
 '0111': 5347,
 '1001': 18,
 '1010': 2,
 '1011': 226,
 '1101': 11,
 '1111': 58}
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.