plans.stochastic.bayes#
Bayes Theorem updating on a discrete hypothesis grid.
Functions
|
Get the accumulated probability along the grid. |
|
Get the grid range where |
|
Get the likelihood on a hypothesis grid from a weighted evidence histogram. |
|
Get the posterior probability using the Bayes Theorem. |
- plans.stochastic.bayes.get_likelihood(evidence, weights, grid, baseline)[source]#
Get the likelihood on a hypothesis grid from a weighted evidence histogram.
- Parameters:
evidence (
numpy.ndarray) – vector of evidence valuesweights (
numpy.ndarray) – vector of evidence weightsgrid (
numpy.ndarray) – hypothesis grid, used as histogram edgesbaseline (float) – value added to every grid point, so none has zero likelihood
- Returns:
normalized likelihood, same size as
grid- Return type:
numpy.ndarray
- plans.stochastic.bayes.get_posterior(prior, likelihood)[source]#
Get the posterior probability using the Bayes Theorem.
- Parameters:
prior (
numpy.ndarray) – vector of prior probabilitieslikelihood (
numpy.ndarray) – vector of likelihoods
- Returns:
normalized posterior
- Return type:
numpy.ndarray
- plans.stochastic.bayes.get_accumulated(probabilities)[source]#
Get the accumulated probability along the grid.
- Parameters:
probabilities (
numpy.ndarray) – vector of probabilities- Returns:
accumulated probabilities
- Return type:
numpy.ndarray
- plans.stochastic.bayes.get_band(grid, accumulated, lower, upper)[source]#
Get the grid range where
lower < accumulated <= upper.- Parameters:
grid (
numpy.ndarray) – hypothesis gridaccumulated (
numpy.ndarray) – vector of accumulated probabilitieslower (float) – lower accumulated probability
upper (float) – upper accumulated probability
- Returns:
lowest and highest grid values, or NaN if no grid point qualifies
- Return type:
tuple