Frames No Frames Cognitoware API v2009512

Class BayesDistribution<X, Y>
X: The type of the prior distribution.
Y: The type of the x used to update the prior distribution.

Cognitoware.Mathematics.Probability.BayesDistribution<X, Y>


Updates a distribution over type X with an x of type Y to get a new distribution over type X.

Constructor Summary

BayesDistribution(RandomDistribution<X>, RandomConditional<Y>, Y)
Creates a BayesDistribution chain using a prior distribution, a conditional distribution, and an x.

Method Summary

Attempts to convert this distribution in the type specified by T.
Creates a new BayesDistribution using this distribution as the prior, the same conditional distribution, and a new x.
Inherited from System.Object
EstimateNormalizer(IEnumerable<X>, Double)
Performs a simple integration on the distribution to estimate the normalization factor.
Inherited from System.Object
Inherited from Cognitoware.Mathematics.Probability.RandomDistribution
Inherited from System.Object
Inherited from System.Object
Inherited from System.Object
Calculates the probability of a value of X using Bayes Rule
Not implemented in BayesDistribution.
Inherited from System.Object


BayesDistribution updates a distribution over type X with an x of type Y to get a new distribution over type X. The new distribution is conditioned on Y and is represented with the expression P(X|Y). Bayes rule is used to perform this update [ P(X|Y) = P(X) * P(Y|X) / P(Y) ]. For a fixed value of X, P(Y|X) gives a probability distribution of observing Y. For a fixed value of Y, P(Y|X) gives a likelihood function (not a probability distribution) of X. P(Y) for a fixed value of Y acts as a normalization constant to ensure P(X|Y) sums to one for any value of Y. P(Y|X) is sometimes referred to as a sensor model. BayesDistribution does not actually perform any calculations on instantiation. It simply chains the classes together and calculates the probability of a value when it is requested. BayesDistribution also does not automatically calculate the normalization factor. The user is responsible for estimating and setting the normalization factor. BayesDistribution can be used with any type of distribution while classes like the Kalman filter are limited to Gaussian distributions. By default, BayesDistibution assumes the normalization constant P(Y) is 1.0. This means that the probability values in the distribution are proportional to the true probability. Values uniformly sampled from this distribution can be selected using Monte Carlo sampling on their proportional probabilities to get a true sample from this distribution.

Constructor Details

public BayesDistribution(RandomDistribution<X> prior, RandomConditional<Y> sensorModel, Y observation)
Creates a BayesDistribution chain using a prior distribution, a conditional distribution, and an x.


prior - The initial distribution of X.
sensorModel - The sensor model that gives the probability of observing Y given a value of X
observation - An observed value of Y

Method Details

public override T AliasAs()
Gets the likelihood function resulting when the observed data is bound to the sensor model and attempts to cast it to the specified type. This is most likely to succeed if the sensor model is implemented by LikelihoodMap.


This distribution as type T or null if the distribution cannot be converted.

public BayesDistribution<X> ChainObservation(Y y)
Simply constructs a new BayesDistribution using the following expression: "new BayesDistribution<X, Y>(this, this.SensorModel, range)". "this" acts as the prior distrubition. "SensorModel" is reused as the sensor model. "range" is the new x.


y - The new x used to perform the next Bayesian inference step.


A new distribution conditioned on the parameter value.

public Double EstimateNormalizer(IEnumerable<X> domain, Double dx)
The domain should generate equally spaced values across X. Dx is the distance between each step. EstimateNormalizer performs a simple integration across this distribution. This distribution is evaluated for each value of X in domain. This value is the multiplied by dx and added to a sum. Domain should be large enough to cover most of the distribution (although this can be difficult to guarantee for a complex distribution.) The domain parameter can be created with a function containing yield statements.


domain - Each value returned by this enumeration will be used as a value in the integration.
dx - The width of each integration value

public override Double ProbabilityOf(X x)
All returned value of result are proportionate to the true probability of result. These proportionate values can be used to sample from the distribution. The user can set the Normalizer property to get a true probability distribution.


x - The value whose probability is calculated.


The probability of result.

public override X Sample(Random select)
Implements the abstract method in RandomDistribution. Throws NotImplementedException.

Questions, Comments and Licensing
Copyright 2009 Cognitoware. All rights reserved.