import numpy as np
import pysps
x = np.arange(10)
pi = pysps.InclusionProb(x, 6)OrderSample
OrderSample(pi, prn=None, *, shape=1.0, sort_method='partial')Order sampling with fixed distribution shape.
Parameters
pi : InclusionProb-
Inclusion probabilities for units in the population.
prn : ArrayLike = None-
Permanent random numbers. Should be a flat array of values, the same length as
pi, distributed uniform between 0 and 1. The default draws a sample without permanent random numbers. shape : float = 1.0-
Shape parameter for the generalized Pareto distribution that is used as the fixed order distribution shape. The default is sequential Poisson sampling. Setting shape=0 gives Successive sampling and shape=-1 gives Pareto order sampling.
sort_method : (partial, stable) = 'partial'-
Sorting method to use for drawing the sample. The default uses a partial sort. Use ‘stable’ if ties should resolve in order.
Attributes
units : Array-
Indices for units in the sample.
weights : Array-
Design weights for units in the sample.
take_all : Array-
Take-all units in the sample.
take_some : Array-
Take-some units in the sample.
prn : Array-
Random numbers used for drawing the sample.
References
Matei, A., and Tillé, Y. (2007). Computational aspects of order πps sampling schemes. Computational Statistics & Data Analysis, 51: 3703-3717.
Ohlsson, E. (1998). Sequential Poisson Sampling. Journal of Official Statistics, 14(2): 149-162.
Rosén, B. (1997). On sampling with probability proportional to size. Journal of Statistical Planning and Inference, 62(2): 159-191.
Examples
# Draw a sequential Poisson sample using permanent random numbers.
prn = np.random.default_rng(54321).uniform(size=10)
sample = pysps.OrderSample(pi, prn)
sample.unitsarray([3, 4, 5, 7, 8, 9])
# Get the design weights.
sample.weightsarray([2.33333333, 1.75 , 1.4 , 1. , 1. ,
1. ])
# Units 0 to 2 are take-some units...
sample.take_somearray([0, 1, 2])
# ... and units 3 to 5 are take-all units.
sample.take_allarray([3, 4, 5])
# Draw a Pareto order sample using the same permanent random numbers.
pysps.OrderSample(pi, prn, shape=-1).unitsarray([3, 5, 6, 7, 8, 9])