Click or drag to resize
Accord.NET (logo)

MultivariateEmpiricalDistribution Class

Multivariate empirical distribution.
Inheritance Hierarchy
SystemObject
  Accord.Statistics.DistributionsDistributionBase
    Accord.Statistics.Distributions.MultivariateMultivariateContinuousDistribution
      Accord.Statistics.Distributions.MultivariateMultivariateEmpiricalDistribution

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

The MultivariateEmpiricalDistribution type exposes the following members.

Constructors
  NameDescription
Public methodMultivariateEmpiricalDistribution(Double)
Creates a new Empirical Distribution from the data samples.
Public methodMultivariateEmpiricalDistribution(Double, Double)
Creates a new Empirical Distribution from the data samples.
Public methodMultivariateEmpiricalDistribution(Double, Int32)
Creates a new Empirical Distribution from the data samples.
Public methodMultivariateEmpiricalDistribution(IDensityKernel, Double)
Creates a new Empirical Distribution from the data samples.
Public methodMultivariateEmpiricalDistribution(Double, Double, Double)
Creates a new Empirical Distribution from the data samples.
Public methodMultivariateEmpiricalDistribution(Double, Int32, Double)
Creates a new Empirical Distribution from the data samples.
Public methodMultivariateEmpiricalDistribution(IDensityKernel, Double, Double)
Creates a new Empirical Distribution from the data samples.
Public methodMultivariateEmpiricalDistribution(IDensityKernel, Double, Double)
Creates a new Empirical Distribution from the data samples.
Public methodMultivariateEmpiricalDistribution(IDensityKernel, Double, Int32)
Creates a new Empirical Distribution from the data samples.
Public methodMultivariateEmpiricalDistribution(IDensityKernel, Double, Double, Double)
Creates a new Empirical Distribution from the data samples.
Public methodMultivariateEmpiricalDistribution(IDensityKernel, Double, Int32, Double)
Creates a new Empirical Distribution from the data samples.
Top
Properties
  NameDescription
Public propertyCounts
Gets the repetition counts associated with each sample. Note that changing values on this array will not result int any effect in this distribution. The distribution must be computed from scratch with new values in case new weights needs to be used.
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 propertyKernel
Gets the kernel density function used in this distribution.
Public propertyLength
Gets the total number of samples in this 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 propertySamples
Gets the samples giving this empirical distribution.
Public propertySmoothing
Gets the bandwidth smoothing parameter used in the kernel density estimation.
Public propertyVariance
Gets the variance for this distribution.
(Overrides MultivariateContinuousDistributionVariance.)
Public propertyWeights
Gets the fractional weights associated with each sample. Note that changing values on this array will not result int any effect in this distribution. The distribution must be computed from scratch with new values in case new weights needs to be used.
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 methodFit(Double, Double, IFittingOptions)
Fits the underlying distribution to a given set of observations.
(Overrides MultivariateContinuousDistributionFit(Double, Double, IFittingOptions).)
Public methodFit(Double, Double, MultivariateEmpiricalOptions)
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.
(Overrides MultivariateContinuousDistributionFit(Double, Int32, IFittingOptions).)
Public methodFit(Double, Int32, MultivariateEmpiricalOptions)
Fits the underlying distribution to a given set of observations.
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, Int32, Random)
Generates a random vector of observations 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 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.
(Inherited from MultivariateContinuousDistribution.)
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.)
Public methodStatic memberSilvermanRule(Double)
Gets the Silverman's rule. estimative of the smoothing parameter. This is the default smoothing rule applied used when estimating MultivariateEmpiricalDistributions.
Public methodStatic memberSilvermanRule(Double, Double)
Gets the Silverman's rule. estimative of the smoothing parameter. This is the default smoothing rule applied used when estimating MultivariateEmpiricalDistributions.
Public methodStatic memberSilvermanRule(Double, Int32)
Gets the Silverman's rule. estimative of the smoothing parameter. This is the default smoothing rule applied used when estimating MultivariateEmpiricalDistributions.
Public methodStatic memberSilvermanRule(Double, Double, Int32)
Gets the Silverman's rule. estimative of the smoothing parameter. This is the default smoothing rule applied used when estimating MultivariateEmpiricalDistributions.
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

Empirical distributions are based solely on the data. This class uses the empirical distribution function and the Gaussian kernel density estimation to provide an univariate continuous distribution implementation which depends only on sampled data.

References:

Examples

The first example shows how to fit a MultivariateEmpiricalDistribution using Gaussian kernels:

// Suppose we have the following data, and we would
// like to estimate a distribution from this data

double[][] samples =
{
    new double[] { 0, 1 },
    new double[] { 1, 2 },
    new double[] { 5, 1 },
    new double[] { 7, 1 },
    new double[] { 6, 1 },
    new double[] { 5, 7 },
    new double[] { 2, 1 },
};

// Start by specifying a density kernel
IDensityKernel kernel = new GaussianKernel(dimension: 2);

// The density kernel gives a window function centered in a particular sample. 
// By creating one of those windows for each sample, we can achieve an empirical 
// multivariate distribution function. An output example for a single Gaussian 
// kernel would be:
double z = kernel.Function(new double[] { 0, 1 }); // should be 0.096532352630053914


// Create a multivariate Empirical distribution from the samples
var dist = new MultivariateEmpiricalDistribution(kernel, samples);

// Common measures
double[] mean = dist.Mean;       // { 3.71, 2.00 }
double[] median = dist.Median;   // { 3.71, 2.00 }
double[] var = dist.Variance;    // { 7.23, 5.00 } (diagonal from cov)
double[,] cov = dist.Covariance; // { { 7.23, 0.83 }, { 0.83, 5.00 } }

// Probability mass functions
double pdf1 = dist.ProbabilityDensityFunction(new double[] { 2, 1 });    // 0.017657515909330332
double pdf2 = dist.ProbabilityDensityFunction(new double[] { 4, 2 });    // 0.011581172997320841
double pdf3 = dist.ProbabilityDensityFunction(new double[] { 5, 7 });    // 0.0072297668067630525
double lpdf = dist.LogProbabilityDensityFunction(new double[] { 5, 7 }); // -4.929548496891365

The second example shows how to the same as above, but using Epanechnikov kernels instead.

// Suppose we have the following data, and we would
// like to estimate a distribution from this data

double[][] samples =
{
    new double[] { 0, 1 },
    new double[] { 1, 2 },
    new double[] { 5, 1 },
    new double[] { 7, 1 },
    new double[] { 6, 1 },
    new double[] { 5, 7 },
    new double[] { 2, 1 },
};

// Start by specifying a density kernel
IDensityKernel kernel = new EpanechnikovKernel(dimension: 2);

// Create a multivariate Empirical distribution from the samples
var dist = new MultivariateEmpiricalDistribution(kernel, samples);


// Common measures
double[] mean = dist.Mean;     // { 3.71, 2.00 }
double[] median = dist.Median; // { 3.71, 2.00 }
double[] var = dist.Variance;  // { 7.23, 5.00 } (diagonal from cov)
double[,] cov = dist.Covariance; // { { 7.23, 0.83 }, { 0.83, 5.00 } }

// Probability mass functions
double pdf1 = dist.ProbabilityDensityFunction(new double[] { 2, 1 }); // 0.039131176997318849
double pdf2 = dist.ProbabilityDensityFunction(new double[] { 4, 2 }); // 0.010212109770266639
double pdf3 = dist.ProbabilityDensityFunction(new double[] { 5, 7 }); // 0.02891906722705221
double lpdf = dist.LogProbabilityDensityFunction(new double[] { 5, 7 }); // -3.5432541357714742
See Also