PQC
Get introduced to the concept of PQC and implement the basic pqc-function.
from functools import reducefrom qiskit import QuantumCircuit, Aer, execute, ClassicalRegister, QuantumRegisterfrom math import asin, sqrt, ceilfrom qiskit.visualization import plot_histogramimport matplotlib.pyplot as pltdef 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 measurementqr = QuantumRegister(7)cr = ClassicalRegister(1)qc = QuantumCircuit(qr, cr) if measure else QuantumCircuit(qr)# INSERT QUANTUM CIRCUIT HEREqc = QuantumCircuit(4)# measure the qubit only if we want the measurement to be includedif 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-functionqc=QuantumCircuit(7)
Get hands-on with 1200+ tech skills courses.