Sampling API¶
Sampling configuration lives in gmm_divergence.sampling. These objects are
used by Monte Carlo divergence estimators and sampled fitting objectives.
gmm_divergence.sampling
¶
Public sampling configuration API.
Draw
dataclass
¶
Bases: SampleSpec, BatchSampleSpec
Draw fresh samples from the Gaussian-family distribution being estimated.
Use this when the estimator or fitting objective should own sampling.
Passing a seed or generator through rng makes repeated calls
reproducible.
rng
class-attribute
instance-attribute
¶
Random generator or seed used when drawing samples.
sample
¶
sample(distribution: GaussianLike) -> FloatArray
Return the batch of samples corresponding to the given distribution.
sample_batches
¶
sample_batches(distributions: Sequence[GaussianLike]) -> FloatArray
Return one independently drawn sample batch per distribution.
Source code in src/gmm_divergence/_core/_sampling.py
Stratified
dataclass
¶
Bases: SampleSpec, BatchSampleSpec
Draw stratified samples from a Gaussian-family distribution.
For a Gaussian mixture, component sample counts are allocated
deterministically from the mixture weights, then samples are drawn from each
component. Every positive-weight component receives at least one sample, so
n_samples must be at least the number of positive-weight components. A
single Gaussian is treated as a one-component mixture.
n_samples
class-attribute
instance-attribute
¶
Total number of samples to draw.
rng
class-attribute
instance-attribute
¶
Random generator or seed used when drawing samples.
sample
¶
sample(distribution: GaussianLike) -> FloatArray
Return the batch of samples corresponding to the given distribution.
sample_batches
¶
sample_batches(distributions: Sequence[GaussianLike]) -> FloatArray
Return one stratified sample batch per distribution.
Source code in src/gmm_divergence/_core/_sampling.py
Samples
dataclass
¶
Bases: SampleSpec
Use precomputed samples from a single Gaussian-family reference distribution.
sample
¶
sample(distribution: GaussianLike) -> FloatArray
Return the batch of samples corresponding to the given distribution.
SampleBatches
dataclass
¶
Bases: BatchSampleSpec
Use precomputed sample batches for a sequence of candidate distributions.
samples
instance-attribute
¶
Sample array with shape (n_distributions, n_samples, n_features).
sample_batches
¶
sample_batches(distributions: Sequence[GaussianLike]) -> FloatArray
Return precomputed sample batches for the given distributions.