Press + to interact
from functools import reduce
from qiskit import QuantumCircuit, Aer, execute, ClassicalRegister, QuantumRegister
from math import asin, sqrt, ceil
from qiskit.visualization import plot_histogram
import matplotlib.pyplot as plt
def prob_to_angle(prob):
"""
Converts a given P(psi) value into an equivalent theta value.
"""
return 2*asin(sqrt(prob))
def pqc(backend, prior, modifiers, shots=1, hist=False, measure=False):
# Prepare the circuit with qubits and a classical bit to hold the measurement
qr = QuantumRegister(7)
cr = ClassicalRegister(1)
qc = QuantumCircuit(qr, cr) if measure else QuantumCircuit(qr)
# INSERT QUANTUM CIRCUIT HERE
qc = QuantumCircuit(4)
# measure the qubit only if we want the measurement to be included
if measure:
qc.measure(qr[0], cr[0])
results = execute(qc,backend, shots=shots).result().get_counts()
return plot_histogram(results, figsize=(12,4)) if hist else results
#CAPTION The basic pqc-function
qc=QuantumCircuit(7)

Get hands-on with 1200+ tech skills courses.