Priors

class orbitize.priors.GaussianPrior(mu, sigma, no_negatives=True)[source]

Gaussian prior.

\[log(p(x|\sigma, \mu)) \propto \frac{(x - \mu)}{\sigma}\]
Parameters
  • mu (float) – mean of the distribution

  • sigma (float) – standard deviation of the distribution

  • no_negatives (bool) – if True, only positive values will be drawn from this prior, and the probability of negative values will be 0 (default:True).

(written) Sarah Blunt, 2018

compute_lnprob(element_array)[source]

Compute log(probability) of an array of numbers wrt a Gaussian distibution. Negative numbers return a probability of -inf.

Parameters

element_array (float or np.array of float) – array of numbers. We want the probability of drawing each of these from the appopriate Gaussian distribution

Returns

array of log(probability) values, corresponding to the probability of drawing each of the numbers in the input element_array.

Return type

numpy array of float

draw_samples(num_samples)[source]

Draw positive samples from a Gaussian distribution. Negative samples will not be returned.

Parameters

num_samples (float) – the number of samples to generate

Returns

samples drawn from the appropriate Gaussian distribution. Array has length num_samples.

Return type

numpy array of float

class orbitize.priors.KDEPrior(gaussian_kde, total_params, bounds=[], log_scale_arr=[])[source]

Gaussian kernel density estimation (KDE) prior. This class is a wrapper for scipy.stats.gaussian_kde.

Parameters
  • gaussian_kde (scipy.stats.gaussian_kde) – scipy KDE object containing the KDE defined by the user

  • total_params (float) – number of parameters in the KDE

  • bounds (array_like of bool, optional) – bounds for the KDE out of which the prob returned is -Inf

  • bounds – if True for a parameter the parameter is fit to the KDE in log-scale

Written: Jorge LLop-Sayson, Sarah Blunt (2021)

compute_lnprob(element_array)[source]

Compute log(probability) of an array of numbers wrt a the defined KDE. Negative numbers return a probability of -inf.

Parameters

element_array (float or np.array of float) – array of numbers. We want the probability of drawing each of these from the KDE.

Returns

array of log(probability) values, corresponding to the probability of drawing each of the numbers in the input element_array.

Return type

numpy array of float

draw_samples(num_samples)[source]

Draw positive samples from the KDE. Negative samples will not be returned.

Parameters

num_samples (float) – the number of samples to generate.

Returns

samples drawn from the KDE distribution. Array has length num_samples.

Return type

numpy array of float

increment_param_num()[source]

Increment the index to evaluate the appropriate parameter.

class orbitize.priors.LinearPrior(m, b)[source]

Draw samples from the probability distribution:

\[p(x) \propto mx+b\]

where m is negative, b is positive, and the range is [0,-b/m].

Parameters
  • m (float) – slope of line. Must be negative.

  • b (float) – y intercept of line. Must be positive.

draw_samples(num_samples)[source]

Draw samples from a descending linear distribution.

Parameters

num_samples (float) – the number of samples to generate

Returns

samples ranging from [0, -b/m) as floats.

Return type

np.array

class orbitize.priors.LogUniformPrior(minval, maxval)[source]

This is the probability distribution \(p(x) \propto 1/x\)

The __init__ method should take in a “min” and “max” value of the distribution, which correspond to the domain of the prior. (If this is not implemented, the prior has a singularity at 0 and infinite integrated probability).

Parameters
  • minval (float) – the lower bound of this distribution

  • maxval (float) – the upper bound of this distribution

compute_lnprob(element_array)[source]

Compute the prior probability of each element given that its drawn from a Log-Uniofrm prior

Parameters

element_array (float or np.array of float) – array of paramters to compute the prior probability of

Returns

array of prior probabilities

Return type

np.array

draw_samples(num_samples)[source]

Draw samples from this 1/x distribution.

Parameters

num_samples (float) – the number of samples to generate

Returns

samples ranging from [minval, maxval) as floats.

Return type

np.array

class orbitize.priors.NearestNDInterpPrior(interp_fct, total_params)[source]

Nearest Neighbor interp. This class is a wrapper for scipy.interpolate.NearestNDInterpolator.

Parameters
  • interp_fct (scipy.interpolate.NearestNDInterpolator) – scipy Interpolator object containing the NDInterpolator defined by the user

  • total_params (float) – number of parameters

Written: Jorge LLop-Sayson (2021)

compute_lnprob(element_array)[source]

Compute log(probability) of an array of numbers wrt a the defined ND interpolator. Negative numbers return a probability of -inf.

Parameters

element_array (float or np.array of float) – array of numbers. We want the probability of drawing each of these from the ND interpolator.

Returns

array of log(probability) values, corresponding to the probability of drawing each of the numbers in the input element_array.

Return type

numpy array of float

draw_samples(num_samples)[source]

Draw positive samples from the ND interpolator. Negative samples will not be returned.

Parameters

num_samples (float) – the number of samples to generate.

Returns

samples drawn from the ND interpolator distribution. Array has length num_samples.

Return type

numpy array of float

increment_param_num()[source]

Increment the index to evaluate the appropriate parameter.

class orbitize.priors.Prior[source]

Abstract base class for prior objects. All prior objects should inherit from this class.

Written: Sarah Blunt, 2018

class orbitize.priors.SinPrior[source]

This is the probability distribution \(p(x) \propto sin(x)\)

The domain of this prior is [0,pi].

compute_lnprob(element_array)[source]

Compute the prior probability of each element given that its drawn from a sine prior

Parameters

element_array (float or np.array of float) – array of paramters to compute the prior probability of

Returns

array of prior probabilities

Return type

np.array

draw_samples(num_samples)[source]

Draw samples from a Sine distribution.

Parameters

num_samples (float) – the number of samples to generate

Returns

samples ranging from [0, pi) as floats.

Return type

np.array

class orbitize.priors.UniformPrior(minval, maxval)[source]

This is the probability distribution p(x) propto constant.

Parameters
  • minval (float) – the lower bound of the uniform prior

  • maxval (float) – the upper bound of the uniform prior

compute_lnprob(element_array)[source]

Compute the prior probability of each element given that its drawn from this uniform prior

Parameters

element_array (float or np.array of float) – array of paramters to compute the prior probability of

Returns

array of prior probabilities

Return type

np.array

draw_samples(num_samples)[source]

Draw samples from this uniform distribution.

Parameters

num_samples (float) – the number of samples to generate

Returns

samples ranging from [0, pi) as floats.

Return type

np.array

orbitize.priors.all_lnpriors(params, priors)[source]

Calculates log(prior probability) of a set of parameters and a list of priors

Parameters
  • params (np.array) – size of N parameters

  • priors (list) – list of N prior objects corresponding to each parameter

Returns

prior probability of this set of parameters

Return type

float