import numpy as np
import pysps
= np.arange(10)
x = pysps.InclusionProb(x, 6) pi
OrderSample
=None, *, shape=1.0, sort_method='partial') OrderSample(pi, prn
Order sampling scheme 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. shape=1 => Sequential Poisson sampling (the default) shape=0 => Successive sampling shape=-1 => 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.
= np.random.default_rng(54321).uniform(size=10)
prn = pysps.OrderSample(pi, prn)
sample sample.units
array([3, 4, 5, 7, 8, 9])
# Get the design weights.
sample.weights
array([2.33333333, 1.75 , 1.4 , 1. , 1. ,
1. ])
# Units 0 to 2 are take-some units...
sample.take_some
array([0, 1, 2])
# ... and units 3 to 5 are take-all units.
sample.take_all
array([3, 4, 5])
# Draw a Pareto order sample using the same permanent random numbers.
=-1).units pysps.OrderSample(pi, prn, shape
array([3, 5, 6, 7, 8, 9])