quri_parts.core.sampling.shots_allocator module#

create_equipartition_shots_allocator(shot_unit=1)#

Returns a PauliSamplingShotsAllocator that distributes the number of shots equally among the groups.

Parameters:

shot_unit (int) – Unit of shot counts. Each distributed number of shots is rounded down to the nearest multiple of this number. (default: 1)

Return type:

core.sampling.PauliSamplingShotsAllocator

Note

The sum of allocated shots may be less than total_shots due to the rounding.

create_proportional_shots_allocator(shot_unit=1)#

Returns a PauliSamplingShotsAllocator that distributes the number of shots in a way that is proportional to the target coefficient.

The number of shots for measurement group \(i\), \(n_i\), is determined by

\[n_i = \frac{w_i}{\sum_j w_j}\]

where \(w_j\) is a weight for the \(j\)-th measurement group that is defined by the Euclidean norm of the coefficients among Pauli terms of the \(j\)-th measurement group.

References

D. Wecker, M. B. Hastings, and M. Troyer, Phys. Rev. A 92, 042303 (2015). M. Kohda, R. Imai, et al., arXiv:2112.07416 (2021). See Appendix D.

Parameters:

shot_unit (int) – Unit of shot counts. Each distributed number of shots is rounded down to the nearest multiple of this number. (default: 1)

Return type:

core.sampling.PauliSamplingShotsAllocator

Note

The sum of allocated shots may be less than total_shots due to the rounding.

create_weighted_random_shots_allocator(seed=1, shot_unit=1)#

Returns a PauliSamplingShotsAllocator that distributes the number of shots by sampling from a multinomial probability distribution defined by the target coefficients. The probability is determined by eq. (10) in the reference below.

References

Operator Sampling for Shot-frugal Optimization in Variational Algorithms Andrew Arrasmith, Lukasz Cincio, Rolando D. Somma, and Patrick J. Coles, arXiv:2004.06252 (2020)

Parameters:
  • seed (int) – Seed used to initialize NumPy’s default_rng.

  • shot_unit (int) – Unit of shot counts. Each distributed number of shots is multiple of this number. (default: 1)

Return type:

core.sampling.PauliSamplingShotsAllocator

Note

If shot_unit is greater than 1, the quotient total_shots // shot_unit is once distributed to each group by multinomial distribution, and then each of them is multiplied by shot_unit. In this case, the sum of allocated shots may be less than total_shots.