Statistical Operations#
Statistical operations are simulator specific mathematical operations allowing you to compute properties of the simulated quantum state without making it collapse.
All statistical operations will result in a real or complex number that will be stored in the Z-Register, and can be accessed from the results of the simulation through the zstates option, see Circuits page.
On this page you will find all statistical operations available on QLEO with explanations and examples.
Contents#
Expectation value#
Mathematical definition#
An expectation value for a pure state \(| \psi \rangle\) is defined as
where \(O\) is an operator. With respect to a density matrix \(\rho\) it’s given by
Usage on QLEO#
First we need to define the operator \(O\) of which we will compute the expectation value
>>> op = SigmaPlus()
SigmaPlus is only one of the many operators available. Of course, every gate can be used as an operator, for example op = GateZ().
However, QLEO also supports many non-unitary operators such as SigmaPlus, more about this on the Operators page.
To ask QLEO to compute the expectation value for a circuit you can create an ExpectationValue object and push() it to the circuit like this:
>>> circuit = Circuit()
>>> circuit.push(GateH(), 0)
1-qubit circuit with 1 instructions:
└── H @ q[0]
>>> # Ask to compute the expectation value
>>> ev = ExpectationValue(op)
>>> circuit.push(ev, 0, 0)
1-qubit circuit with 2 instructions:
├── H @ q[0]
└── ⟨SigmaPlus(1)⟩ @ q[0], z[0]
push() function always follow the order of quantum register index first, classical register second (none in this case), and Z-register index last.0 is the index for the first qubit of the quantum register and the second 0 is the index of the Z-Register.Notice that the expectation value will be computed with respect to the quantum state of the system at the point in the circuit where the ExpectationValue is added.
Amplitude#
Amplitude.You can add the Amplitude object to the circuit exactly like any other gate:
>>> mystery_circuit = Circuit()
>>> mystery_circuit.push(GateH(), range(0, 3))
3-qubit circuit with 3 instructions:
├── H @ q[0]
├── H @ q[1]
└── H @ q[2]
>>> # Define the Amplitude operator
>>> amp = Amplitude(BitString("101"))
>>> # Add the amplitude operator to the circuit and write the result in the first complex number of the Z-Register
>>> mystery_circuit.push(amp, 0)
3-qubit circuit with 4 instructions:
├── H @ q[0]
├── H @ q[1]
├── H @ q[2]
└── Amplitude(bs"101") @ z[0]
This will extract the amplitude of the basis state \(\ket{101}\). When adding the amplitude operation you do not need to give it any specific qubit target, the only index needed is for the Z-register to use for storing the result.