Priors
Prior distributions.
Probability Distribution Container
- class eryn.prior.ProbDistContainer(priors_in, use_cupy=False, return_gpu=False)
Bases:
objectContainer 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
logpdfandrvsmethods.
- priors_in
Dictionary with keys as int or tuple of int describing which parameters the prior takes. Values are probability distributions with
logpdfandrvsmethods.- 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. IfFalseuse Numpy. (default:False)- Type:
bool, optional
- return_gpu
If
True, return CuPy array. IfFalse, return Numpy array. (default:False)- Type:
bool, optional
- Raises:
ValueError – Missing parameters or incorrect index keys.
- property xp
Numpy or Cupy
- 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_indictionary for the__init__function. Even when using this kwarg, must provide allndimparameters 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
rvsmethod. This means that generated points may lay inside the prior of all input priors that havervsmethods, but outside the prior if priors without thervsmethod 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_indictionary 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, return_gpu=False)
Generate uniform distribution between
minandmax- Parameters:
min (double) – Minimum in the uniform distribution
max (double) – Maximum in the uniform distribution
use_cupy (bool, optional) – If
True, use CuPy. IfFalseuse Numpy. (default:False)return_gpu (bool, optional) – If
True, return CuPy array. IfFalse, return Numpy array. (default:False)
- Returns:
Uniform distribution.
- Return type:
UniformDistribution
- eryn.prior.log_uniform(min, max)
Generate log-uniform distribution between
minandmax- 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, return_gpu=False)
Bases:
objectMaps 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
minandmaxvalues input by user. This ensures the log of the prior value from this distribution is zero if the value is betweenminandmax. and-np.infif 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. IfFalseuse Numpy. (default:False)return_gpu (bool, optional) – If
True, return CuPy array. IfFalse, return Numpy array. (default:False)
- Raises:
ValueError – If
minis greater thanmax.
- property xp
Numpy or Cupy
- 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