Accord.NET (logo) JointDistribution Class Accord.NET Framework
Online Show table of contents (goes to the online documentation index).
Joint distribution of multiple discrete univariate distributions.
Inheritance Hierarchy

Online System Object
  Accord.Statistics.Distributions DistributionBase
    Accord.Statistics.Distributions.Multivariate MultivariateDiscreteDistribution
      Accord.Statistics.Distributions.Multivariate JointDistribution

Namespace: Accord.Statistics.Distributions.Multivariate
Assembly: Accord.Statistics (in Accord.Statistics.dll) Version: 2.10.0.0 (2.10.0.4632)
Syntax

[SerializableAttribute]
public class JointDistribution : MultivariateDiscreteDistribution
Remarks

This class builds a (potentially huge) lookup table for discrete symbol distributions. For example, given a discrete variable A which may take symbols a, b, c; and a discrete variable B which may assume values x, y, z, this class will build the probability table:

       x      y      z
a   p(a,x) p(a,y) p(a,z)
b   p(b,x) p(b,y) p(b,z)
c   p(c,x) p(c,y) p(c,z)

Thus comprising the probabilities for all possible simple combination. This distribution is a generalization of the GeneralDiscreteDistribution for multivariate discrete observations.

Examples

The following example should demonstrate how to estimate a joint distribution of two discrete variables. The first variable can take up to three distinct values, whereas the second can assume up to five.

// Lets create a joint distribution for two discrete variables: 
// the first of which can assume 3 distinct symbol values: 0, 1, 2 
// the second which can assume 5 distinct symbol values: 0, 1, 2, 3, 4 

int[] symbols = { 3, 5 }; // specify the symbol counts 

// Create the joint distribution for the above variables
JointDistribution joint = new JointDistribution(symbols);

// Now, suppose we would like to fit the distribution (estimate 
// its parameters) from the following multivariate observations: 
//  
double[][] observations = 
{
    new double[] { 0, 0 },
    new double[] { 1, 1 },
    new double[] { 2, 1 },
    new double[] { 0, 0 },
};


// Estimate parameters
joint.Fit(observations);

// At this point, we can query the distribution for observations: 
double p1 = joint.ProbabilityMassFunction(new[] { 0, 0 }); // should be 0.50 
double p2 = joint.ProbabilityMassFunction(new[] { 1, 1 }); // should be 0.25 
double p3 = joint.ProbabilityMassFunction(new[] { 2, 1 }); // should be 0.25 

// As it can be seem, indeed {0,0} appeared twice at the data,  
// and {1,1} and {2,1 appeared one fourth of the data each.
See Also