qxmt.kernels.sampling module#
- qxmt.kernels.sampling.generate_all_observable_states(n_qubits, state_pattern='01')
Generate all possible observable states for the given number of qubits.
- Parameters:
n_qubits (int) – number of qubits
state_pattern (str, optional) – pattern of the observable state. Defaults to “01”.
- Returns:
list of all possible observable states
- Return type:
list[str]
- qxmt.kernels.sampling.sample_results_to_probs(result, n_qubits, shots, state_pattern='01')
Convert the sampling results to the probability of each
- Parameters:
result (np.ndarray) – numpy array of sampling results
n_qubits (int) – number of qubits
shots (int) – number of shots
state_pattern (str, optional) – pattern of the observable state. Defaults to “01”.
- Returns:
numpy array of the probability of each state
- Return type:
np.ndarray
- qxmt.kernels.sampling.validate_sampling_values(sampling_result, valid_values=[0, 1])
Validate the sampling resutls of each shots.
- Parameters:
sampling_result (np.ndarray) – array of sampling results
valid_values (list[int], optional) – valid value of quantum state. Defaults to [0, 1].
- Raises:
ValueError – invalid values in the sampling results
- Return type:
None