Quick Example
Quantum Coin Flip: Quantum Circuit Example
Sample a 50/50 measurement distribution
What this example teaches
Sample a balanced one-qubit distribution in a simulator.
Expected result
Outcomes 0 and 1 each have ideal probability 1/2. A software simulator does not certify physical randomness.
Browser bit strings list physical wires q0 first, including auxiliary wires. Native classical-register strings can use another order; inspect the declared measurements.
These are ideal probabilities. Sampled frequencies fluctuate when more than one outcome is possible; they need not match percentages exactly. An ideal outcome with probability 100% has no finite-shot variation. Hardware noise is a separate effect.
Try the example
The link opens the editor. Save existing work, then choose Examples → Quantum Coin Flip → framework. Click Run, choose an available browser simulator, then click Run in browser. The link does not preselect or execute the example.
Scope and limitations
- Simulator samples use a software random-number generator; this is not a physical random-number certification.
These expected answers describe the fixed circuit. This page does not establish a completed hosted or hardware run. Read the user guide for this example.
Inspect and download the circuit
Inspect the same fixed circuit in five frameworks. Browser execution translates supported circuit definitions into OpenQASM; it does not run general Python. Outside Marqov, Qiskit, Cirq, and Marqov snippets need a separate simulator invocation. PennyLane invokes its QNode and stores sampled counts in result.
OpenQASM
// Quantum Coin Flip — ideal 50/50 measurement (simulators use pseudorandom sampling)
OPENQASM 2.0;
include "qelib1.inc";
qreg q[1];
creg c[1];
h q[0];
measure q[0] -> c[0];
Download OpenQASM circuitQiskit
# Quantum Coin Flip — ideal 50/50 measurement (simulators use pseudorandom sampling)
from qiskit import QuantumCircuit
qc = QuantumCircuit(1, 1)
qc.h(0)
qc.measure(0, 0)
Download Qiskit circuitCirq
# Quantum Coin Flip — ideal 50/50 measurement (simulators use pseudorandom sampling)
import cirq
q = cirq.LineQubit(0)
circuit = cirq.Circuit([
cirq.H(q),
cirq.measure(q, key="coin"),
])
Download Cirq circuitPennyLane
# Quantum Coin Flip — ideal 50/50 measurement (simulators use pseudorandom sampling)
import pennylane as qml
dev = qml.device("default.qubit", wires=1, shots=1000)
@qml.qnode(dev)
def coin_flip():
qml.Hadamard(wires=0)
return qml.counts()
result = coin_flip()
Download PennyLane circuitMarqov
# Quantum Coin Flip — ideal 50/50 measurement (simulators use pseudorandom sampling)
from marqov import Circuit
circuit = Circuit().h(0)
Download Marqov circuitSources and provenance
These references explain the concept and gate conventions. The snippets originate in Marqov's internal example collection; an upstream code attribution has not been established.
Snapshot identity
- Source revision
df5a80cd474144684bf69dbda237b28ce40cc48c- Example version
6ecd5d3196dc167e2c662375cc78cde1b7959477b7420c9f78dc06de07b63f72
The source revision identifies the editor collection used for this snapshot. The example version identifies its five exact code variants; neither is evidence of a hosted run.
Go deeper
For a paper-based experiment with scientific comparisons and execution evidence, read Research Replications. Its published scope and availability are separate from this small teaching circuit.