rxmc.priors.IndependentPrior#
- class rxmc.priors.IndependentPrior(distributions: list, seed: int = 123)[source]#
Bases:
objectIndependent prior built from an arbitrary list of
scipy.statsdistributions.Each parameter component
jis modelled by the corresponding frozen distributiondistributions[j]. The components are treated as independent, so the joint log-density is the sum of the marginal log-densities, and sampling draws from each marginal separately.This class satisfies the generic prior protocol required by
ParameterConfig: it exposeslogpdf,rvs, andprior_transform, and carries adimattribute used for automatic dimension validation.- Parameters:
distributions (list of frozen scipy.stats distributions) – One distribution per parameter component. Any frozen univariate
scipy.statsdistribution works (e.g.stats.norm(0, 1),stats.uniform(0, 5),stats.truncnorm(...)).seed (int, optional) – Seed for the internal
numpy.random.Generatorused inrvs()to ensure reproducibility. Default is123.
Examples
>>> from scipy import stats >>> from rxmc.priors import IndependentPrior >>> prior = IndependentPrior([stats.norm(0, 1), stats.uniform(0, 5)]) >>> prior.dim 2 >>> prior.rvs(4).shape (4, 2)
Methods
__init__(distributions[, seed])logpdf(theta)Evaluate the joint log prior density.
Map unit-cube coordinates to physical parameters (Dynesty interface).
rvs(n)Draw
nindependent samples from the prior.- logpdf(theta)[source]#
Evaluate the joint log prior density.
- Parameters:
theta (array-like) – Parameter vector of shape
(ndim,)for a single evaluation, or(n, ndim)for a batch ofnvectors.- Returns:
float or ndarray – Scalar log-density when
thetahas shape(ndim,); array of shape(n,)whenthetahas shape(n, ndim).- Raises:
ValueError – If the trailing dimension of
thetadoes not equalself.dim.
- rvs(n: int) ndarray[source]#
Draw
nindependent samples from the prior.- Parameters:
n (int) – Number of samples to draw.
- Returns:
ndarray, shape (n, ndim) – Matrix of samples, one row per draw.
- prior_transform(u) ndarray[source]#
Map unit-cube coordinates to physical parameters (Dynesty interface).
Applies the percent-point function (inverse CDF) of each marginal distribution component-wise.
- Parameters:
u (array-like, shape (ndim,)) – Unit-cube coordinates, each in
[0, 1).- Returns:
ndarray, shape (ndim,) – Physical parameter vector.