lib.parameter.Prior

class lib.parameter.Prior(dist='uniform', limits=None, **kwargs)

Bases: lib.utils.BaseClass

Class that describes a 1D prior distribution.

Parameters
  • dist (string) – Distribution name.

  • rv (scipy.stats.rv_continuous) – Random variate.

  • attrs (dict) – Arguments used to initialize rv.

Initialize Prior.

Parameters
  • dist (string) – Distribution name in scipy.stats

  • limits (tuple, default=None) – Limits. See set_limits().

  • kwargs (dict) – Arguments for scipy.stats.dist(), typically loc, scale (mean and standard deviation in case of a normal distribution 'dist' == 'norm')

Methods

copy

Return shallow copy of self.

deepcopy

from_state

Instantiate and initalize class with state dictionary.

is_limited

Whether distribution has (at least one) finite limit.

is_mpi_broadcast

is_mpi_gathered

is_mpi_root

is_mpi_scattered

is_proper

Whether distribution is proper, i.e. has finite integral.

isin

Whether x is within prior, i.e. within limits - strictly positive probability.

load

Load class in numpy binary format from disk.

load_auto

If different formats are possible, this method should between them based on file name extension.

log_critical

log_debug

log_error

log_info

log_warning

sample

Draw size samples from prior.

save

Save class to disk.

save_auto

If different formats are possible, this method should between them based on file name extension.

set_limits

Set limits.

Attributes

logger

mpiattrs

MPI attributes

mpicomm

mpiroot

mpistate

__call__(x)

Return probability density at x.

copy()

Return shallow copy of self.

classmethod from_state(state, mpiroot=0, mpicomm=None)

Instantiate and initalize class with state dictionary.

is_limited()

Whether distribution has (at least one) finite limit.

is_proper()

Whether distribution is proper, i.e. has finite integral.

isin(x)

Whether x is within prior, i.e. within limits - strictly positive probability.

classmethod load(filename, mpiroot=0, mpicomm=None)

Load class in numpy binary format from disk. If the loaded state contains __class__ and that exists in cls._registry, return instance of cls._registry[__class__] (instead of cls).

load_auto(*args, **kwargs)

If different formats are possible, this method should between them based on file name extension.

property mpiattrs

MPI attributes

sample(size=None, random_state=None)

Draw size samples from prior. Possible only if prior is proper.

Parameters
Returns

samples – Samples drawn from prior.

Return type

float, array

save(filename)

Save class to disk.

save_auto(*args, **kwargs)

If different formats are possible, this method should between them based on file name extension.

set_limits(limits=None)

Set limits.

Parameters

limits (tuple, default=None) – Tuple corresponding to lower, upper limits. None means \(-\infty\) for lower bound and \(\infty\) for upper bound. Defaults to \(-\infty,\infty\).