I am trying to implement the following task using Python and Qiskit, but I am not sure of the code that I need to write. The task is as follows.

Input to the code: $n$ qubits.

Here is an illustration of the output of the code. For purposes of illustration, let $n$ be $4$:

  • Start from the state $|0\rangle^{\otimes 4}.$
  • Apply a random two-qubit unitary to qubits $1$ and $2$, and then to $3$ and $4$.
  • Apply a random two-qubit unitary to qubits $2$ and $3$.

Measure the output in the standard basis. Do this many times and calculate the probability of $\mathbb{E}\big[p_{0^{4}}^{2}\big],$ where the expectation is taken over the random gates and $p_{0^{4}}$ is the probability of getting $0000$.

For each run of this code, I also want a plot of the probability distribution for each of the $2^{4}$ strings possible in the output.

  • $\begingroup$ Please indicate an example of the code and the functions you already know. Have you ever worked with Qiskit? How deep is the answer would depend on this. $\endgroup$
    – Mauricio
    Jul 15 at 16:34
  • $\begingroup$ I think all the components you need can be found in Qiskit textbook: qiskit.org/textbook/ch-quantum-hardware/… $\endgroup$
    – Mauricio
    Jul 15 at 16:37


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.