AssertMeasurementProbability operation

Namespace: Microsoft.Quantum.Diagnostics

Package: Microsoft.Quantum.QSharp.Foundation

Asserts that measuring the given qubits in the given Pauli basis will have the given result with the given probability, within some tolerance.

operation AssertMeasurementProbability (bases : Pauli[], qubits : Qubit[], result : Result, prob : Double, msg : String, tolerance : Double) : Unit is Adj + Ctl

Input

bases : Pauli[]

A measurement effect to assert the probability of, expressed as a multi-qubit Pauli operator.

qubits : Qubit[]

A register on which to make the assertion.

result : Result

An expected result of Measure(bases, qubits).

prob : Double

The probability with which the given result is expected.

msg : String

A message to be reported if the assertion fails.

tolerance : Double

Tolerance allowed in the measurement probability.

Output : Unit

Example

using (register = Qubit()) {
    H(register);
    AssertMeasurementProbability([PauliZ], [register], One, 0.5,
        "Measuring in conjugate basis did not give 50/50 results.", 1e-5);
}

Remarks

Note that the Adjoint and Controlled versions of this operation will not check the condition.

See Also