rxmc.priors.TruncatedNormalPrior#

class rxmc.priors.TruncatedNormalPrior(mu, sigma, lower, upper, seed=123)[source]#

Bases: object

Independent truncated-normal prior for a vector of parameters.

Each component j follows:

theta_j ~ Normal(mu_j, sigma_j),  truncated to [lower_j, upper_j]

The components are treated as independent, so the joint log-density is the sum of the marginal log-densities.

Parameters:
  • mu (array-like, shape (ndim,)) – Mean of the untruncated normal for each component.

  • sigma (array-like, shape (ndim,)) – Standard deviation of the untruncated normal for each component.

  • lower (array-like, shape (ndim,)) – Lower truncation bound for each component.

  • upper (array-like, shape (ndim,)) – Upper truncation bound for each component.

  • seed (int, optional) – Seed for the internal random-number generator used in rvs(). Default is 123.

__init__(mu, sigma, lower, upper, seed=123)[source]#

Methods

__init__(mu, sigma, lower, upper[, 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)[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)[source]#

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

Parameters:

u (array-like, shape (ndim,)) – Unit-cube coordinates, each in [0, 1).

Returns:

ndarray, shape (ndim,) – Physical parameter vector obtained by applying the component-wise percent-point function of each truncated normal.