pylfi.priors.Prior¶
- class pylfi.priors.Prior(distr_name, *params, name=None, tex=None, **kwargs)[source]¶
Initialize a prior.
In the Bayesian paradigm, all available information about an unknown parameter is incorporated in a prior probability distribution, which describes the range of possible parameter values.
- Parameters
- distr_name
str Any distribution from
scipy.statsas a string.- params:
Parameters of the prior distribution. Typically these would be
shapeparameters orlocandscalepassed as positional arguments.- name
str Name of the unknown parameter, which is used to keep track and access the parameter in the sampling algorithms. Default:
None.- tex
str, optional LaTeX typesetting for the parameter name.
pyLFIincludes procedures for automatically plotting priors and posteriors, and will use thetexname of the parameter as axis labels if provided. Default:None.- kwargs:
kwargs are passed to the scipy distribution methods. Typically these would be
locandscale.
- distr_name
Attributes
Name of the
scipy.statsdistribution.Parameter name.
Parameter name with LaTeX typesetting.
Methods
logpdf(x)Evaluate the log of the probability density function (pdf).
pdf(x)Evaluate the probability density function (pdf).
plot_prior(x[, color, facecolor, alpha, ax])Plot prior pdf or pmf evaluated at
x.pmf(x)Evaluate the probability mass function (pmf).
rvs([size, seed])Draw random variate.
- rvs(size=None, seed=None)[source]¶
Draw random variate.
- Parameters
- Returns
- rvs
numpy.ndarray Random variables.
- rvs
- pdf(x)[source]¶
Evaluate the probability density function (pdf).
Method for continuous distributions.
- Parameters
- xarray_like
Evaluation points.
- Returns
- pdf
numpy.ndarray pdf evaluated at
x.
- pdf
- logpdf(x)[source]¶
Evaluate the log of the probability density function (pdf).
Method for continuous distributions.
- Parameters
- xarray_like
Evaluation points.
- Returns
- logpdf
numpy.ndarray Log of pdf evaluated at
x.
- logpdf
- pmf(x)[source]¶
Evaluate the probability mass function (pmf).
Method for discrete distributions.
- Parameters
- xarray_like
Evaluation points.
- Returns
- pmf
numpy.ndarray pmf evaluated at
x.
- pmf
- property distr_name¶
Name of the
scipy.statsdistribution.- Returns
- plot_prior(x, color='C0', facecolor='lightblue', alpha=0.5, ax=None, **kwargs)[source]¶
Plot prior pdf or pmf evaluated at
x.- Parameters
- xarray_like
Evaluation points.
- color
str, optional Set the color of the line. Default:
C0.- facecolor
str, optional Set the face color of area under the curve. Default:
lightblue.- alpha
float, optional Set the alpha value used for blending the face color. Must be within the 0-1 range. Default:
0.5.- ax
matplotlib.axes.Axes, optional Pre-existing axes for the plot. Otherwise, call
matplotlib.pyplot.gcainternally.- kwargs:
kwargs are passed to
matplotlib.pyplot.plot.