Priors
Prior distributions.
Probability Distribution Container
- class eryn.prior.ProbDistContainer(priors_in, use_cupy=False)
Bases:
object
Container for holding and generating prior info
- Parameters:
priors_in (dict) – Dictionary with keys as int or tuple of int describing which parameters the prior takes. Values are probability distributions with
logpdf
andrvs
methods.
- priors_in
Dictionary with keys as int or tuple of int describing which parameters the prior takes. Values are probability distributions with
logpdf
andrvs
methods.- Type:
dict
- priors
list of indexes and their associated distributions arranged in a list.
- Type:
list
- ndim
Full dimensionality.
- Type:
int
- use_cupy
If
True
, use CuPy. IfFalse
use Numpy. (default:False
)- Type:
bool, optional
- Raises:
ValueError – Missing parameters or incorrect index keys.
- logpdf(x, keys=None)
Get logpdf by summing logpdf of individual distributions
- Parameters:
x (double np.ndarray[..., ndim]) – Input parameters to get prior values.
keys (list, optional) – List of keys related to which parameters to gather the logpdf for. They must exactly match the input keys for the
priors_in
dictionary for the__init__
function. Even when using this kwarg, must provide allndim
parameters as input. The prior will just not be calculated if its associated key is not included. Default isNone
.
- Returns:
Prior values.
- Return type:
np.ndarray[…]
- ppf(x, groups=None)
Get logpdf by summing logpdf of individual distributions
- Parameters:
x (double np.ndarray[..., ndim]) – Input parameters to get prior values.
- Returns:
Prior values.
- Return type:
np.ndarray[…]
- rvs(size=1, keys=None)
Generate random values according to prior distribution
The user will have to be careful if there are prior functions that do not have an
rvs
method. This means that generated points may lay inside the prior of all input priors that havervs
methods, but outside the prior if priors without thervs
method are included.- Parameters:
size (int or tuple of ints, optional) – Output size for number of generated sources from prior distributions.
keys (list, optional) – List of keys related to which parameters to generate. They must exactly match the input keys for the
priors_in
dictionary for the__init__
function. If used, it will produce and output array oftuple(size) + (len(keys),)
. Default isNone
.
- Returns:
Generated samples.
- Return type:
np.ndarray[
size + (self.ndim,)
]- Raises:
ValueError – If size is not an int or tuple.
Available Probability Distributions
- eryn.prior.uniform_dist(min, max, use_cupy=False)
Generate uniform distribution between
min
andmax
- Parameters:
min (double) – Minimum in the uniform distribution
max (double) – Maximum in the uniform distribution
use_cupy (bool, optional) – If
True
, use CuPy. IfFalse
use Numpy. (default:False
)
- Returns:
Uniform distribution.
- Return type:
UniformDistribution
- eryn.prior.log_uniform(min, max)
Generate log-uniform distribution between
min
andmax
- Parameters:
min (double) – Minimum in the log-uniform distribution
max (double) – Maximum in the log-uniform distribution
- Returns:
- Log-uniform distribution built from
scipy.stats.uniform <https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.loguniform.html>_.
- Return type:
scipy distribution object
- class eryn.prior.MappedUniformDistribution(min, max, use_cupy=False)
Bases:
object
Maps uniform distribution to zero to 1.
This is a modified uniform distribution that maps the input values to a range from zero to 1 by using
min
andmax
values input by user. This ensures the log of the prior value from this distribution is zero if the value is betweenmin
andmax
. and-np.inf
if it is outside that range.- Parameters:
min (double) – Minimum in the uniform distribution
max (double) – Maximum in the uniform distribution
use_cupy (bool, optional) – If
True
, use CuPy. IfFalse
use Numpy. (default:False
)
- Raises:
ValueError – If
min
is greater thanmax
.
- logpdf(x)
Get the log of the pdf value for this distribution.
- Parameters:
x (double np.ndarray) – Input parameters to get prior values.
- Returns:
Associated logpdf values of the input.
- Return type:
np.ndarray
- rvs(size=1)
Get the log of the pdf value for this distribution.
- Parameters:
size (int or tuple of ints, optional) – Output size for number of generated sources from prior distributions.
- Returns:
Generated values.
- Return type:
np.ndarray