qrunch.quantum.estimators.diagonal_weighted_z_strings

Helpers for estimating \(\langle Z_Q W \rangle\) from computational basis distributions.

Here \(Z_Q\) is a Z string on the qubits \(Q\) and \(W = \sum_p w_p Z_p\) a diagonal weight operator. Estimators with access to the distribution of computational basis states (exact probabilities or sampled frequencies) can evaluate these directly, instead of expanding \(W\) into one Pauli string per qubit.

Functions

error_mitigator_preserves_z_strings(...)

Return whether the error mitigator leaves Z-string observables unchanged.

z_strings_with_diagonal_weight_from_distribution(...)

Compute \(\langle Z_Q W \rangle\) for each Z string in z_strings from a basis state distribution.

error_mitigator_preserves_z_strings(error_mitigator: EstimatorErrorMitigator | None) → bool

Return whether the error mitigator leaves Z-string observables unchanged.

Parameters:

error_mitigator (EstimatorErrorMitigator | None) – The error mitigator of the estimator.

Return type:

bool

z_strings_with_diagonal_weight_from_distribution(bitstrings: Iterable[int], probabilities: Iterable[float], weights: NDArray[float64], z_strings: NDArray[int64]) → NDArray[float64]

Compute \(\langle Z_Q W \rangle\) for each Z string in z_strings from a basis state distribution.

The distribution is a probability (or sampled frequency) per computational basis state. \(Z_Q\) is the product of Pauli Z on the qubits \(Q\) of a Z string, and \(W = \sum_p w_p Z_p\) with \(Z_p\) the Pauli Z on qubit \(p\) and \(w_p\) = weights[p].

Parameters:
  • bitstrings (Iterable[int]) – The basis states as integers, where qubit q is bit q. States with zero probability may be left out.

  • probabilities (Iterable[float]) – The probability (or sampled frequency) of each basis state.

  • weights (NDArray[float64]) – The weight \(w_p\) of every qubit \(p\).

  • z_strings (NDArray[int64]) – One Z string per row, given by its qubit indices and padded with -1.

Return type:

NDArray[float64]