glearn.priors.Prior#
- class glearn.priors.Prior(half=False)#
Base class for prior distributions.
Warning
This class is a base class and does not implement a kernel function. Use the derivative of this class instead.
See also
Examples
Create Prior Objects:
Create the inverse Gamma distribution (see
glearn.priors.InverseGamma
) with the shape parameter \(\alpha=4\) and rate parameter \(\beta=2\).>>> from glearn import priors >>> prior = priors.InverseGamma(4, 2) >>> # Evaluate PDF function at multiple locations >>> t = [0, 0.5, 1] >>> prior.pdf(t) array([ nan, 1.56293452, 0.36089409]) >>> # Evaluate the Jacobian of the PDF >>> prior.pdf_jacobian(t) array([ nan, -3.12586904, -1.08268227]) >>> # Evaluate the Hessian of the PDF >>> prior.pdf_hessian(t) array([[ nan, 0. , 0. ], [ 0. , -12.50347615, 0. ], [ 0. , 0. , 3.60894089]]) >>> # Evaluate the log-PDF >>> prior.log_pdf(t) -17.15935597045384 >>> # Evaluate the Jacobian of the log-PDF >>> prior.log_pdf_jacobian(t) array([ -6.90775528, -10.05664278, -11.05240845]) >>> # Evaluate the Hessian of the log-PDF >>> prior.log_pdf_hessian(t) array([[-10.60379622, 0. , 0. ], [ 0. , -3.35321479, 0. ], [ 0. , 0. , -1.06037962]]) >>> # Plot the distribution and its first and second derivative >>> prior.plot()
Where to Use the Prior object:
Define a covariance model (see
glearn.Covariance
) where its scale parameter is a prior function.>>> # Generate a set of sample points >>> from glearn.sample_data import generate_points >>> points = generate_points(num_points=50) >>> # Create covariance object of the points with the above kernel >>> from glearn import covariance >>> cov = glearn.Covariance(points, kernel=kernel, scale=prior)
- Attributes:
- use_log_scalebool, default=True
If True, the input argument to the functions is assumed to be the logarithm of the hyperparameter \(\theta\). If False, the input argument to the functions is assumed to be the hyperparameter \(\theta\).
- halfbool, default=False
If True, the probability distribution is assumed to be the half-distribution.
Methods
log_pdf
(hyperparam)Logarithm of the probability density function of the prior distribution.
log_pdf_jacobian
(hyperparam)Jacobian of the logarithm of the probability density function of the prior distribution.
log_pdf_hessian
(hyperparam)Hessian of the logarithm of the probability density function of the prior distribution.
plot
([interval, log_scale, ...])Plot the kernel function and its first and second derivative.