plans.stochastic.bayes#

Bayes Theorem updating on a discrete hypothesis grid.

Functions

get_accumulated(probabilities)

Get the accumulated probability along the grid.

get_band(grid, accumulated, lower, upper)

Get the grid range where lower < accumulated <= upper.

get_likelihood(evidence, weights, grid, baseline)

Get the likelihood on a hypothesis grid from a weighted evidence histogram.

get_posterior(prior, likelihood)

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 values

  • weights (numpy.ndarray) – vector of evidence weights

  • grid (numpy.ndarray) – hypothesis grid, used as histogram edges

  • baseline (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 probabilities

  • likelihood (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 grid

  • accumulated (numpy.ndarray) – vector of accumulated probabilities

  • lower (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