quri_parts.core.sampling.weighted_shots_allocator module#
- create_equipartition_generic_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.WeightedSamplingShotsAllocator
Note
The sum of allocated shots may be less than total_shots due to the rounding.
- create_proportional_generic_shots_allocator(shot_unit=1)#
Returns a
PauliSamplingShotsAllocator
that distributes the number of shots proportionately to a set of weights.- 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.WeightedSamplingShotsAllocator
Note
The sum of allocated shots may be less than total_shots due to the rounding.
- create_weighted_random_generic_shots_allocator(seed=1, shot_unit=1)#
Returns a
PauliSamplingShotsAllocator
that distributes the number of shots according to a multinomial probability distribution defined by the target coefficients. The probability is determined by eq. (10) in the reference below. Although here we substitute an arbitrary sequence of weights for the coefficients mentioned in the paper.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.WeightedSamplingShotsAllocator
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.