jwspecmcmc.priors
Prior distributions for MCMC sampling.
Provides prior classes that can be composed into a PriorSet
for use with the MCMC samplers. Default priors are uniform within the
parameter bounds from jwspecfit.fitter._grating_bounds().
Functions
|
Build a |
Classes
|
Truncated Gaussian prior. |
|
Log-uniform (Jeffreys) prior on |
|
Abstract base class for a 1-D prior distribution. |
|
Collection of priors indexed by free-parameter position. |
|
Uniform (flat) prior on |
- class jwspecmcmc.priors.GaussianPrior(mean, std, lo=-inf, hi=inf)[source]
Bases:
PriorTruncated Gaussian prior.
- Parameters:
- sample(rng, size=1)[source]
Draw random samples from the prior.
- Parameters:
rng (numpy.random.Generator) – Random number generator.
size (int) – Number of samples.
- Returns:
Samples of shape
(size,).- Return type:
np.ndarray
- class jwspecmcmc.priors.LogUniformPrior(lo, hi)[source]
Bases:
PriorLog-uniform (Jeffreys) prior on
[lo, hi]withlo > 0.- sample(rng, size=1)[source]
Draw random samples from the prior.
- Parameters:
rng (numpy.random.Generator) – Random number generator.
size (int) – Number of samples.
- Returns:
Samples of shape
(size,).- Return type:
np.ndarray
- class jwspecmcmc.priors.Prior[source]
Bases:
ABCAbstract base class for a 1-D prior distribution.
- abstractmethod sample(rng, size=1)[source]
Draw random samples from the prior.
- Parameters:
rng (numpy.random.Generator) – Random number generator.
size (int) – Number of samples.
- Returns:
Samples of shape
(size,).- Return type:
np.ndarray
- class jwspecmcmc.priors.PriorSet(priors=<factory>)[source]
Bases:
objectCollection of priors indexed by free-parameter position.
- log_prior(p_free)[source]
Evaluate the total log-prior for a free-parameter vector.
- Parameters:
p_free (np.ndarray) – Free parameter values (length
n_dim).- Returns:
Sum of individual log-priors (
-infif any parameter is outside its support).- Return type:
- sample(rng)[source]
Draw one sample from the joint prior.
- Parameters:
rng (numpy.random.Generator) – Random number generator.
- Returns:
Sample of shape
(n_dim,).- Return type:
np.ndarray
- class jwspecmcmc.priors.UniformPrior(lo, hi)[source]
Bases:
PriorUniform (flat) prior on
[lo, hi].- sample(rng, size=1)[source]
Draw random samples from the prior.
- Parameters:
rng (numpy.random.Generator) – Random number generator.
size (int) – Number of samples.
- Returns:
Samples of shape
(size,).- Return type:
np.ndarray
- jwspecmcmc.priors.priors_from_bounds(lb_free, ub_free, overrides=None)[source]
Build a
PriorSetfrom parameter bounds.- Parameters:
lb_free (np.ndarray) – Lower bounds for free parameters.
ub_free (np.ndarray) – Upper bounds for free parameters.
overrides (dict mapping int to Prior, optional) – Per-index prior overrides.
- Return type: