quri_parts.core.estimator.sampling.estimator module#

get_estimate_from_sampling_result(op, measurement_groups, const, sampling_counts)#

Converts sampling counts into the estimation of the operator’s expectation value.

Parameters:
Return type:

Estimate[complex]

sampling_estimate(op, state, total_shots, sampler, measurement_factory, shots_allocator, circuit_shot_pair_prep_fn=<function get_sampling_circuits_and_shots>)#

Estimate expectation value of a given operator with a given state by sampling measurement.

The sampling measurements are configured with arguments as follows.

Parameters:
  • op (core.estimator.Estimatable) – An operator of which expectation value is estimated.

  • state (CircuitQuantumState) – A quantum state on which the operator expectation is evaluated.

  • total_shots (int) – Total number of shots available for sampling measurements.

  • sampler (core.sampling.ConcurrentSampler) – A Sampler that actually performs the sampling measurements.

  • measurement_factory (core.measurement.interface.CommutablePauliSetMeasurementFactory) – A function that performs Pauli grouping and returns a measurement scheme for Pauli operators constituting the original operator.

  • shots_allocator (core.sampling.PauliSamplingShotsAllocator) – A function that allocates the total shots to Pauli groups to be measured.

  • circuit_shot_pair_prep_fn (core.estimator.sampling.estimator_helpers.CircuitShotPairPreparationFunction) – A CircuitShotPairPreparationFunction that prepares the set of circuits to perform measurement with. It is default to a function that concatenates the measurement circuits after the state preparation circuit.

Returns:

The estimated value (can be accessed with value) with standard error

of estimation (can be accessed with error).

Return type:

Estimate[complex]

create_sampling_estimator(total_shots, sampler, measurement_factory, shots_allocator)#

Create a QuantumEstimator that estimates operator expectation value by sampling measurement.

The sampling measurements are configured with arguments as follows.

Parameters:
  • total_shots (int) – Total number of shots available for sampling measurements.

  • sampler (ConcurrentSampler) – A Sampler that actually performs the sampling measurements.

  • measurement_factory (CommutablePauliSetMeasurementFactory) – A function that performs Pauli grouping and returns a measurement scheme for Pauli operators constituting the original operator.

  • shots_allocator (PauliSamplingShotsAllocator) – A function that allocates the total shots to Pauli groups to be measured.

Return type:

QuantumEstimator[CircuitQuantumState]

concurrent_sampling_estimate(operators, states, total_shots, sampler, measurement_factory, shots_allocator, circuit_shot_pair_prep_fn=<function get_sampling_circuits_and_shots>)#

Estimate expectation value of given operators with given states by sampling measurement.

The sampling measurements are configured with arguments as follows.

Parameters:
  • operators (Collection[core.estimator.Estimatable]) – Operators of which expectation value is estimated.

  • states (Collection[CircuitQuantumState]) – Quantum states on which the operator expectation is evaluated.

  • total_shots (int) – Total number of shots available for sampling measurements.

  • sampler (core.sampling.ConcurrentSampler) – A Sampler that actually performs the sampling measurements.

  • measurement_factory (core.measurement.interface.CommutablePauliSetMeasurementFactory) – A function that performs Pauli grouping and returns a measurement scheme for Pauli operators constituting the original operator.

  • shots_allocator (core.sampling.PauliSamplingShotsAllocator) – A function that allocates the total shots to Pauli groups to be measured.

  • circuit_shot_pair_prep_fn (core.estimator.sampling.estimator_helpers.CircuitShotPairPreparationFunction) – A CircuitShotPairPreparationFunction that prepares the set of circuits to perform measurement with. It is default to a function that concatenates the measurement circuits after the state preparation circuit.

Returns:

The estimated values (can be accessed with value) with standard errors

of estimation (can be accessed with error).

Return type:

Iterable[Estimate[complex]]

create_sampling_concurrent_estimator(total_shots, sampler, measurement_factory, shots_allocator)#

Create a ConcurrentQuantumEstimator that estimates operator expectation value by sampling measurement.

The sampling measurements are configured with arguments as follows.

Parameters:
  • total_shots (int) – Total number of shots available for sampling measurements.

  • sampler (ConcurrentSampler) – A Sampler that actually performs the sampling measurements.

  • measurement_factory (CommutablePauliSetMeasurementFactory) – A function that performs Pauli grouping and returns a measurement scheme for Pauli operators constituting the original operator.

  • shots_allocator (PauliSamplingShotsAllocator) – A function that allocates the total shots to Pauli groups to be measured.

Return type:

ConcurrentQuantumEstimator[CircuitQuantumState]

create_general_sampling_estimator(total_shots, sampler, measurement_factory, shots_allocator)#

Creates a GeneralQuantumEstimator that performs sampling estimation.

Parameters:
  • total_shots (int) – Total number of shots available for sampling measurements.

  • sampler (core.sampling.ConcurrentSampler) – A Sampler that actually performs the sampling measurements.

  • measurement_factory (core.measurement.interface.CommutablePauliSetMeasurementFactory) – A function that performs Pauli grouping and returns a measurement scheme for Pauli operators constituting the original operator.

  • shots_allocator (core.sampling.PauliSamplingShotsAllocator) – A function that allocates the total shots to Pauli groups to be measured.

Return type:

GeneralQuantumEstimator[CircuitQuantumState, ParametricCircuitQuantumState]