RandomMeasurement¶
- class qumeas.random_measurement.RandomShadow(mole: Any | None = None, PauliObj: PauliContainer | None = None, state_prep: StatePreparation | None = None, basis: List[List[int]] | None = None)¶
Bases:
objectClass for estimating expectation values of Pauli strings using classical shadow tomography (randomized measurement basis).
- PauliObj¶
PauliContainer object holding Pauli strings, coefficients, state vector, and number of qubits.
- Type:
- basis¶
Basis for measurements in classical shadow tomography.
- Type:
Optional[List[List[int]]]
- state_prep¶
State preparation object, can be an instance of StatePreparation or qiskitStatePreparation.
- Type:
Optional[StatePreparation]
- outbits¶
Measurement output bits. Contains list of measurement basis and another list of the corresponding classical bits. In the measurement basis, X,Y,Z are represented as integers 1,2,3 respectively.
- Type:
Optional[List[List[List[int]]]]
- compute_expectation(measure_basis, measure_outcome_bits)¶
Compute the expectation value from measurement bits.
- Parameters:
measure_basis (List[Union[str, List[int]]]) – Measurement basis. Either list of Pauli operators (strings) or list of list of int representing Paulis, with 1 = ‘X’, 2 = ‘Y’, and 3 = ‘Z’.
measure_outcome_bits (List[Union[str, List[int]]]) – Measurement outcome (classical bits). Either a list of string or list of list of int. Binary bits can be passed in as string (e.g. [‘0011’, ‘0010’]. Also, supports a list, e.g. [[0, 0, 1, 1], [0, 0, 1, 0]] or in this format: [[1, 1, -1, -1],[1, 1, -1, 1]].
- Returns:
Total expectation value.
- Return type:
float
- get_basis(M: int, seed: int | None = None)¶
Generate a random basis for measurements.
- Parameters:
M (int) – Number of random basis to generate.
seed (Optional[int], default=None) – Random seed for reproducibility.
- measure(shots: int = 1, M: int = 100, seed: int | None = None, nproc: int | None = 1)¶
Perform measurements using the state preparation object (state_prep).
- Parameters:
shots (int, default=1) – Number of measurement shots. Currently, only supports for one shot measurements.
M (int, default=100) – Number of random basis in classical shadow tomography
seed (Optional[int], default=None) – Random seed for reproducibility.
nproc (Optional[int], default=1) – Number of processes for parallelization accross measurement bases. Each measurement basis can be processed in parallel across multiple processes, with each measurement further parallelized using OpenMP for optimal performance.
- Returns:
Computed expectation value.
- Return type:
float