rxmc.priors.IndependentPrior#

class rxmc.priors.IndependentPrior(distributions: list, seed: int = 123)[source]#

Bases: object

Independent prior built from an arbitrary list of scipy.stats distributions.

Each parameter component j is modelled by the corresponding frozen distribution distributions[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 exposes logpdf, rvs, and prior_transform, and carries a dim attribute used for automatic dimension validation.

Parameters:
  • distributions (list of frozen scipy.stats distributions) – One distribution per parameter component. Any frozen univariate scipy.stats distribution works (e.g. stats.norm(0, 1), stats.uniform(0, 5), stats.truncnorm(...)).

  • seed (int, optional) – Seed for the internal numpy.random.Generator used in rvs() to ensure reproducibility. Default is 123.

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)
__init__(distributions: list, seed: int = 123)[source]#

Methods

__init__(distributions[, seed])

logpdf(theta)

Evaluate the joint log prior density.

prior_transform(u)

Map unit-cube coordinates to physical parameters (Dynesty interface).

rvs(n)

Draw n independent 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 of n vectors.

Returns:

float or ndarray – Scalar log-density when theta has shape (ndim,); array of shape (n,) when theta has shape (n, ndim).

Raises:

ValueError – If the trailing dimension of theta does not equal self.dim.

rvs(n: int) ndarray[source]#

Draw n independent 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.