Click or drag to resize
Accord.NET (logo)

JointDistribution Class

Joint distribution of multiple discrete univariate distributions.
Inheritance Hierarchy
SystemObject
  Accord.Statistics.DistributionsDistributionBase
    Accord.Statistics.Distributions.MultivariateMultivariateDiscreteDistribution
      Accord.Statistics.Distributions.MultivariateJointDistribution

Namespace:  Accord.Statistics.Distributions.Multivariate
Assembly:  Accord.Statistics (in Accord.Statistics.dll) Version: 3.8.0
Syntax
[SerializableAttribute]
public class JointDistribution : MultivariateDiscreteDistribution, 
	IFittableDistribution<int[], GeneralDiscreteOptions>, IFittable<int[], GeneralDiscreteOptions>, 
	IFittable<int[]>, IFittableDistribution<int[]>, IDistribution<int[]>, 
	IDistribution, ICloneable, IFittableDistribution<double[]>, IFittable<double[]>, 
	IDistribution<double[]>
Request Example View Source

The JointDistribution type exposes the following members.

Constructors
Properties
  NameDescription
Public propertyCovariance
Gets the variance for this distribution.
(Overrides MultivariateDiscreteDistributionCovariance.)
Public propertyDimension
Gets the number of variables for this distribution.
(Inherited from MultivariateDiscreteDistribution.)
Public propertyFrequencies
Gets the frequency of observation of each discrete variable.
Public propertyItem
Gets or sets the probability value attached to the given index.
Public propertyLengths
Gets the number of symbols in the distribution.
Public propertyMaximum
Gets the integer value where the discrete distribution ends.
Public propertyMean
Gets the mean for this distribution.
(Overrides MultivariateDiscreteDistributionMean.)
Public propertyMedian
Gets the median for this distribution.
(Inherited from MultivariateDiscreteDistribution.)
Public propertyMinimum
Gets the integer value where the discrete distribution starts.
Public propertyMode
Gets the mode for this distribution.
(Inherited from MultivariateDiscreteDistribution.)
Public propertySupport
Gets the support interval for this distribution.
(Overrides MultivariateDiscreteDistributionSupport.)
Public propertySymbols Obsolete.
Gets the number of symbols for each discrete variable.
Public propertyVariance
Gets the mean for this distribution.
(Overrides MultivariateDiscreteDistributionVariance.)
Top
Methods
  NameDescription
Public methodClone
Creates a new object that is a copy of the current instance.
(Overrides DistributionBaseClone.)
Public methodComplementaryDistributionFunction
Gets the complementary cumulative distribution function (ccdf) for this distribution evaluated at point x. This function is also known as the Survival function.
(Inherited from MultivariateDiscreteDistribution.)
Public methodDistributionFunction
Gets the cumulative distribution function (cdf) for this distribution evaluated at point x.
(Inherited from MultivariateDiscreteDistribution.)
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodStatic memberCode exampleEstimate
Estimates a new JointDistribution from a given set of observations.
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodFit(Int32)
Fits the underlying distribution to a given set of observations.
Public methodFit(Double)
Fits the underlying distribution to a given set of observations.
(Inherited from MultivariateDiscreteDistribution.)
Public methodFit(Int32, Double)
Fits the underlying distribution to a given set of observations.
Public methodFit(Double, IFittingOptions)
Fits the underlying distribution to a given set of observations.
(Inherited from MultivariateDiscreteDistribution.)
Public methodFit(Double, Double)
Fits the underlying distribution to a given set of observations.
(Inherited from MultivariateDiscreteDistribution.)
Public methodFit(Double, Int32)
Fits the underlying distribution to a given set of observations.
(Inherited from MultivariateDiscreteDistribution.)
Public methodFit(Double, Double, IFittingOptions)
Fits the underlying distribution to a given set of observations.
(Overrides MultivariateDiscreteDistributionFit(Double, Double, IFittingOptions).)
Public methodFit(Int32, Double, GeneralDiscreteOptions)
Fits the underlying distribution to a given set of observations.
Public methodFit(Double, Int32, IFittingOptions)
Fits the underlying distribution to a given set of observations.
(Inherited from MultivariateDiscreteDistribution.)
Public methodGenerate
Generates a random observation from the current distribution.
(Inherited from MultivariateDiscreteDistribution.)
Public methodGenerate(Double)
Generates a random observation from the current distribution.
(Inherited from MultivariateDiscreteDistribution.)
Public methodGenerate(Int32)
Generates a random vector of observations from the current distribution.
(Inherited from MultivariateDiscreteDistribution.)
Public methodGenerate(Int32)
Generates a random observation from the current distribution.
(Inherited from MultivariateDiscreteDistribution.)
Public methodGenerate(Random)
Generates a random observation from the current distribution.
(Inherited from MultivariateDiscreteDistribution.)
Public methodGenerate(Double, Random)
Generates a random observation from the current distribution.
(Inherited from MultivariateDiscreteDistribution.)
Public methodGenerate(Int32, Double)
Generates a random vector of observations from the current distribution.
(Inherited from MultivariateDiscreteDistribution.)
Public methodGenerate(Int32, Int32)
Generates a random vector of observations from the current distribution.
(Inherited from MultivariateDiscreteDistribution.)
Public methodGenerate(Int32, Random)
Generates a random vector of observations from the current distribution.
(Inherited from MultivariateDiscreteDistribution.)
Public methodGenerate(Int32, Random)
Generates a random observation from the current distribution.
(Inherited from MultivariateDiscreteDistribution.)
Public methodGenerate(Int32, Double, Random)
Generates a random vector of observations from the current distribution.
(Inherited from MultivariateDiscreteDistribution.)
Public methodGenerate(Int32, Int32, Random)
Generates a random vector of observations from the current distribution.
(Inherited from MultivariateDiscreteDistribution.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodInnerComplementaryDistributionFunction
Gets the complementary cumulative distribution function (ccdf) for this distribution evaluated at point x. This function is also known as the Survival function.
(Inherited from MultivariateDiscreteDistribution.)
Protected methodInnerDistributionFunction
Gets the cumulative distribution function (cdf) for this distribution evaluated at point x.
(Overrides MultivariateDiscreteDistributionInnerDistributionFunction(Int32).)
Protected methodInnerInverseDistributionFunction
Not supported.
(Inherited from MultivariateDiscreteDistribution.)
Protected methodInnerLogProbabilityMassFunction
Gets the log-probability mass function (pmf) for this distribution evaluated at point x.
(Overrides MultivariateDiscreteDistributionInnerLogProbabilityMassFunction(Int32).)
Protected methodInnerProbabilityMassFunction
Gets the probability mass function (pmf) for this distribution evaluated at point x.
(Overrides MultivariateDiscreteDistributionInnerProbabilityMassFunction(Int32).)
Public methodInverseDistributionFunction
Not supported.
(Inherited from MultivariateDiscreteDistribution.)
Public methodLogProbabilityMassFunction
Gets the log-probability mass function (pmf) for this distribution evaluated at point x.
(Inherited from MultivariateDiscreteDistribution.)
Public methodMarginalDistributionFunction(Int32)
Gets the marginal distribution of a given variable.
(Inherited from MultivariateDiscreteDistribution.)
Public methodMarginalDistributionFunction(Int32, Int32)
Gets the marginal distribution of a given variable evaluated at a given value.
(Inherited from MultivariateDiscreteDistribution.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodProbabilityMassFunction
Gets the probability mass function (pmf) for this distribution evaluated at point x.
(Inherited from MultivariateDiscreteDistribution.)
Public methodToString
Returns a String that represents this instance.
(Inherited from DistributionBase.)
Public methodToString(IFormatProvider)
Returns a String that represents this instance.
(Inherited from DistributionBase.)
Public methodToString(String)
Returns a String that represents this instance.
(Inherited from DistributionBase.)
Public methodToString(String, IFormatProvider)
Returns a String that represents this instance.
(Overrides DistributionBaseToString(String, IFormatProvider).)
Public methodStatic memberUniform
Constructs a new multidimensional uniform discrete distribution.
Top
Extension Methods
  NameDescription
Public Extension MethodHasMethod
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.)
Public Extension MethodIsEqual
Compares two objects for equality, performing an elementwise comparison if the elements are vectors or matrices.
(Defined by Matrix.)
Public Extension MethodTo(Type)Overloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Public Extension MethodToTOverloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Top
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