Click or drag to resize
Accord.NET (logo)

IndependentTDistribution Class

Joint distribution assuming independence between vector components.
Inheritance Hierarchy

Namespace:  Accord.Statistics.Distributions.Multivariate
Assembly:  Accord.Statistics (in Accord.Statistics.dll) Version: 3.8.0
Syntax
[SerializableAttribute]
public class Independent<TDistribution> : MultivariateContinuousDistribution, 
	ISampleableDistribution<double[]>, IDistribution<double[]>, IDistribution, 
	ICloneable, IRandomNumberGenerator<double[]>, IFittableDistribution<double[], IndependentOptions>, 
	IFittable<double[], IndependentOptions>, IFittable<double[]>, 
	IFittableDistribution<double[]>
where TDistribution : IUnivariateDistribution
Request Example View Source

Type Parameters

TDistribution
The type of the underlying distributions.

The IndependentTDistribution type exposes the following members.

Constructors
  NameDescription
Public methodIndependentTDistribution(Int32)
Initializes a new instance of the IndependentTDistribution class.
Public methodIndependentTDistribution(TDistribution)
Initializes a new instance of the IndependentTDistribution class.
Public methodIndependentTDistribution(Int32, FuncTDistribution)
Initializes a new instance of the IndependentTDistribution class.
Public methodIndependentTDistribution(Int32, FuncInt32, TDistribution)
Initializes a new instance of the IndependentTDistribution class.
Public methodIndependentTDistribution(Int32, TDistribution)
Initializes a new instance of the IndependentTDistribution class.
Top
Properties
  NameDescription
Public propertyComponents
Gets the components of this joint distribution.
Public propertyCovariance
Gets the variance-covariance matrix for this distribution.
(Overrides MultivariateContinuousDistributionCovariance.)
Public propertyDimension
Gets the number of variables for this distribution.
(Inherited from MultivariateContinuousDistribution.)
Public propertyItem
Gets or sets the components of this joint distribution.
Public propertyMean
Gets the mean for this distribution.
(Overrides MultivariateContinuousDistributionMean.)
Public propertyMedian
Gets the median for this distribution.
(Inherited from MultivariateContinuousDistribution.)
Public propertyMode
Gets the mode for this distribution.
(Inherited from MultivariateContinuousDistribution.)
Public propertyVariance
Gets the variance for this distribution.
(Overrides MultivariateContinuousDistributionVariance.)
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 MultivariateContinuousDistribution.)
Public methodDistributionFunction
Gets the probability density function (pdf) for this distribution evaluated at point x.
(Inherited from MultivariateContinuousDistribution.)
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
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(Double)
Fits the underlying distribution to a given set of observations.
(Inherited from MultivariateContinuousDistribution.)
Public methodFit(Double, IFittingOptions)
Fits the underlying distribution to a given set of observations.
(Inherited from MultivariateContinuousDistribution.)
Public methodFit(Double, Double)
Fits the underlying distribution to a given set of observations.
(Inherited from MultivariateContinuousDistribution.)
Public methodFit(Double, Int32)
Fits the underlying distribution to a given set of observations.
(Inherited from MultivariateContinuousDistribution.)
Public methodCode exampleFit(Double, Double, IFittingOptions)
Fits the underlying distribution to a given set of observations.
(Overrides MultivariateContinuousDistributionFit(Double, Double, IFittingOptions).)
Public methodCode exampleFit(Double, Double, IndependentOptions)
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 MultivariateContinuousDistribution.)
Public methodGenerate
Generates a random observation from the current distribution.
(Inherited from MultivariateContinuousDistribution.)
Public methodGenerate(Double)
Generates a random observation from the current distribution.
(Inherited from MultivariateContinuousDistribution.)
Public methodGenerate(Int32)
Generates a random vector of observations from the current distribution.
(Inherited from MultivariateContinuousDistribution.)
Public methodGenerate(Int32)
Generates a random observation from the current distribution.
(Inherited from MultivariateContinuousDistribution.)
Public methodGenerate(Random)
Generates a random observation from the current distribution.
(Inherited from MultivariateContinuousDistribution.)
Public methodGenerate(Double, Random)
Generates a random observation from the current distribution.
(Inherited from MultivariateContinuousDistribution.)
Public methodGenerate(Int32, Double)
Generates a random vector of observations from the current distribution.
(Inherited from MultivariateContinuousDistribution.)
Public methodGenerate(Int32, Int32)
Generates a random vector of observations from the current distribution.
(Inherited from MultivariateContinuousDistribution.)
Public methodGenerate(Int32, Random)
Generates a random vector of observations from the current distribution.
(Inherited from MultivariateContinuousDistribution.)
Public methodGenerate(Int32, Random)
Generates a random observation from the current distribution.
(Inherited from MultivariateContinuousDistribution.)
Public methodGenerate(Int32, Double, Random)
Generates a random vector of observations from the current distribution.
(Overrides MultivariateContinuousDistributionGenerate(Int32, Double, Random).)
Public methodGenerate(Int32, Int32, Random)
Generates a random vector of observations from the current distribution.
(Inherited from MultivariateContinuousDistribution.)
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 MultivariateContinuousDistribution.)
Protected methodInnerDistributionFunction
Gets the probability density function (pdf) for this distribution evaluated at point x.
(Overrides MultivariateContinuousDistributionInnerDistributionFunction(Double).)
Protected methodInnerLogProbabilityDensityFunction
Gets the log-probability density function (pdf) for this distribution evaluated at point x.
(Overrides MultivariateContinuousDistributionInnerLogProbabilityDensityFunction(Double).)
Protected methodInnerProbabilityDensityFunction
Gets the probability density function (pdf) for this distribution evaluated at point x.
(Overrides MultivariateContinuousDistributionInnerProbabilityDensityFunction(Double).)
Public methodLogProbabilityDensityFunction
Gets the log-probability density function (pdf) for this distribution evaluated at point x.
(Inherited from MultivariateContinuousDistribution.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodProbabilityDensityFunction
Gets the probability density function (pdf) for this distribution evaluated at point x.
(Inherited from MultivariateContinuousDistribution.)
Protected methodReset
Resets cached values (should be called after re-estimation).
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).)
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

In probability and statistics, given at least two random variables X, Y, ..., that are defined on a probability space, the joint probability distribution for X, Y, ... is a probability distribution that gives the probability that each of X, Y, ... falls in any particular range or discrete set of values specified for that variable. In the case of only two random variables, this is called a bivariate distribution, but the concept generalizes to any number of random variables, giving a multivariate distribution.

References:

Examples

The following example shows how to declare and initialize an Independent Joint Gaussian Distribution using known means and variances for each component.

// Declare two normal distributions
NormalDistribution pa = new NormalDistribution(4.2, 1); // p(a)
NormalDistribution pb = new NormalDistribution(7.0, 2); // p(b)

// Now, create a joint distribution combining these two:
var joint = new Independent<NormalDistribution>(pa, pb);

// This distribution assumes the distributions of the two components are independent,
// i.e. if we have 2D input vectors on the form {a, b}, then p({a,b}) = p(a) * p(b). 

// Lets check a simple example. Consider a 2D input vector x = { 4.2, 7.0 } as
// 
double[] x = new double[] { 4.2, 7.0 };

// Those two should be completely equivalent:
double p1 = joint.ProbabilityDensityFunction(x);
double p2 = pa.ProbabilityDensityFunction(x[0]) * pb.ProbabilityDensityFunction(x[1]);

bool equal = p1 == p2; // at this point, equal should be true.

The following example shows how to fit a distribution (estimate its parameters) from a given dataset.

  // Let's consider an input dataset of 2D vectors. We would
  // like to estimate an Independent<NormalDistribution>
  // which best models this data.

 double[][] data =
 {
                 // x, y
     new double[] { 1, 8 },
     new double[] { 2, 6 },
     new double[] { 5, 7 },
     new double[] { 3, 9 },
 };

 // We start by declaring some initial guesses for the
 // distributions of each random variable (x, and y):
 // 
 var distX = new NormalDistribution(0, 1);
 var distY = new NormalDistribution(0, 1);

 // Next, we declare our initial guess Independent distribution
 var joint = new Independent<NormalDistribution>(distX, distY);

 // We can now fit the distribution to our data,
 // producing an estimate of its parameters:
 // 
 joint.Fit(data);

 // At this point, we have estimated our distribution. 

 double[] mean = joint.Mean;     // should be { 2.75,  7.50  }
 double[] var  = joint.Variance; // should be { 2.917, 1.667 } 

                                   //        | 2.917,  0.000 |
 double[,] cov = joint.Covariance; //  Cov = |               |
                                   //        | 0.000,  1.667 |

// The covariance matrix is diagonal, as it would be expected
// if is assumed there are no interactions between components.
See Also