MultivariateEmpiricalDistribution Class |
Namespace: Accord.Statistics.Distributions.Multivariate
[SerializableAttribute] public class MultivariateEmpiricalDistribution : MultivariateContinuousDistribution, IFittableDistribution<double[], MultivariateEmpiricalOptions>, IFittable<double[], MultivariateEmpiricalOptions>, IFittable<double[]>, IFittableDistribution<double[]>, IDistribution<double[]>, IDistribution, ICloneable, ISampleableDistribution<double[]>, IRandomNumberGenerator<double[]>
The MultivariateEmpiricalDistribution type exposes the following members.
Name | Description | |
---|---|---|
MultivariateEmpiricalDistribution(Double) |
Creates a new Empirical Distribution from the data samples.
| |
MultivariateEmpiricalDistribution(Double, Double) |
Creates a new Empirical Distribution from the data samples.
| |
MultivariateEmpiricalDistribution(Double, Int32) |
Creates a new Empirical Distribution from the data samples.
| |
MultivariateEmpiricalDistribution(IDensityKernel, Double) |
Creates a new Empirical Distribution from the data samples.
| |
MultivariateEmpiricalDistribution(Double, Double, Double) |
Creates a new Empirical Distribution from the data samples.
| |
MultivariateEmpiricalDistribution(Double, Int32, Double) |
Creates a new Empirical Distribution from the data samples.
| |
MultivariateEmpiricalDistribution(IDensityKernel, Double, Double) |
Creates a new Empirical Distribution from the data samples.
| |
MultivariateEmpiricalDistribution(IDensityKernel, Double, Double) |
Creates a new Empirical Distribution from the data samples.
| |
MultivariateEmpiricalDistribution(IDensityKernel, Double, Int32) |
Creates a new Empirical Distribution from the data samples.
| |
MultivariateEmpiricalDistribution(IDensityKernel, Double, Double, Double) |
Creates a new Empirical Distribution from the data samples.
| |
MultivariateEmpiricalDistribution(IDensityKernel, Double, Int32, Double) |
Creates a new Empirical Distribution from the data samples.
|
Name | Description | |
---|---|---|
Counts |
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.
| |
Covariance |
Gets the variance-covariance matrix for this distribution.
(Overrides MultivariateContinuousDistributionCovariance.) | |
Dimension |
Gets the number of variables for this distribution.
(Inherited from MultivariateContinuousDistribution.) | |
Kernel |
Gets the kernel density function used in this distribution.
| |
Length |
Gets the total number of samples in this distribution.
| |
Mean |
Gets the mean for this distribution.
(Overrides MultivariateContinuousDistributionMean.) | |
Median |
Gets the median for this distribution.
(Inherited from MultivariateContinuousDistribution.) | |
Mode |
Gets the mode for this distribution.
(Inherited from MultivariateContinuousDistribution.) | |
Samples |
Gets the samples giving this empirical distribution.
| |
Smoothing |
Gets the bandwidth smoothing parameter
used in the kernel density estimation.
| |
Variance |
Gets the variance for this distribution.
(Overrides MultivariateContinuousDistributionVariance.) | |
Weights |
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.
|
Name | Description | |
---|---|---|
Clone |
Creates a new object that is a copy of the current instance.
(Overrides DistributionBaseClone.) | |
ComplementaryDistributionFunction |
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.) | |
DistributionFunction |
Gets the probability density function (pdf) for
this distribution evaluated at point x.
(Inherited from MultivariateContinuousDistribution.) | |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
Fit(Double) |
Fits the underlying distribution to a given set of observations.
(Inherited from MultivariateContinuousDistribution.) | |
Fit(Double, IFittingOptions) |
Fits the underlying distribution to a given set of observations.
(Inherited from MultivariateContinuousDistribution.) | |
Fit(Double, Double) |
Fits the underlying distribution to a given set of observations.
(Inherited from MultivariateContinuousDistribution.) | |
Fit(Double, Int32) |
Fits the underlying distribution to a given set of observations.
(Inherited from MultivariateContinuousDistribution.) | |
Fit(Double, Double, IFittingOptions) |
Fits the underlying distribution to a given set of observations.
(Overrides MultivariateContinuousDistributionFit(Double, Double, IFittingOptions).) | |
Fit(Double, Double, MultivariateEmpiricalOptions) |
Fits the underlying distribution to a given set of observations.
| |
Fit(Double, Int32, IFittingOptions) |
Fits the underlying distribution to a given set of observations.
(Overrides MultivariateContinuousDistributionFit(Double, Int32, IFittingOptions).) | |
Fit(Double, Int32, MultivariateEmpiricalOptions) |
Fits the underlying distribution to a given set of observations.
| |
Generate |
Generates a random observation from the current distribution.
(Inherited from MultivariateContinuousDistribution.) | |
Generate(Double) |
Generates a random observation from the current distribution.
(Inherited from MultivariateContinuousDistribution.) | |
Generate(Int32) |
Generates a random vector of observations from the current distribution.
(Inherited from MultivariateContinuousDistribution.) | |
Generate(Int32) |
Generates a random observation from the current distribution.
(Inherited from MultivariateContinuousDistribution.) | |
Generate(Random) |
Generates a random observation from the current distribution.
(Inherited from MultivariateContinuousDistribution.) | |
Generate(Double, Random) |
Generates a random observation from the current distribution.
(Inherited from MultivariateContinuousDistribution.) | |
Generate(Int32, Double) |
Generates a random vector of observations from the current distribution.
(Inherited from MultivariateContinuousDistribution.) | |
Generate(Int32, Int32) |
Generates a random vector of observations from the current distribution.
(Inherited from MultivariateContinuousDistribution.) | |
Generate(Int32, Random) |
Generates a random vector of observations from the current distribution.
(Inherited from MultivariateContinuousDistribution.) | |
Generate(Int32, Random) |
Generates a random observation from the current distribution.
(Inherited from MultivariateContinuousDistribution.) | |
Generate(Int32, Int32, Random) |
Generates a random vector of observations from the current distribution.
(Inherited from MultivariateContinuousDistribution.) | |
Generate(Int32, Double, Random) |
Generates a random vector of observations from the current distribution.
(Overrides MultivariateContinuousDistributionGenerate(Int32, Double, Random).) | |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
InnerComplementaryDistributionFunction |
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.) | |
InnerDistributionFunction |
Gets the probability density function (pdf) for
this distribution evaluated at point x.
(Overrides MultivariateContinuousDistributionInnerDistributionFunction(Double).) | |
InnerLogProbabilityDensityFunction |
Gets the log-probability density function (pdf)
for this distribution evaluated at point x.
(Inherited from MultivariateContinuousDistribution.) | |
InnerProbabilityDensityFunction |
Gets the probability density function (pdf) for
this distribution evaluated at point x.
(Overrides MultivariateContinuousDistributionInnerProbabilityDensityFunction(Double).) | |
LogProbabilityDensityFunction |
Gets the log-probability density function (pdf)
for this distribution evaluated at point x.
(Inherited from MultivariateContinuousDistribution.) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
ProbabilityDensityFunction |
Gets the probability density function (pdf) for
this distribution evaluated at point x.
(Inherited from MultivariateContinuousDistribution.) | |
SilvermanRule(Double) |
Gets the Silverman's rule. estimative of the smoothing parameter.
This is the default smoothing rule applied used when estimating
MultivariateEmpiricalDistributions.
| |
SilvermanRule(Double, Double) |
Gets the Silverman's rule. estimative of the smoothing parameter.
This is the default smoothing rule applied used when estimating
MultivariateEmpiricalDistributions.
| |
SilvermanRule(Double, Int32) |
Gets the Silverman's rule. estimative of the smoothing parameter.
This is the default smoothing rule applied used when estimating
MultivariateEmpiricalDistributions.
| |
SilvermanRule(Double, Double, Int32) |
Gets the Silverman's rule. estimative of the smoothing parameter.
This is the default smoothing rule applied used when estimating
MultivariateEmpiricalDistributions.
| |
ToString |
Returns a String that represents this instance.
(Inherited from DistributionBase.) | |
ToString(IFormatProvider) |
Returns a String that represents this instance.
(Inherited from DistributionBase.) | |
ToString(String) |
Returns a String that represents this instance.
(Inherited from DistributionBase.) | |
ToString(String, IFormatProvider) |
Returns a String that represents this instance.
(Overrides DistributionBaseToString(String, IFormatProvider).) |
Name | Description | |
---|---|---|
HasMethod |
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.) | |
IsEqual |
Compares two objects for equality, performing an elementwise
comparison if the elements are vectors or matrices.
(Defined by Matrix.) | |
To(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.) | |
ToT | 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.) |
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:
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