EmpiricalDistribution Class 
Namespace: Accord.Statistics.Distributions.Univariate
[SerializableAttribute] public class EmpiricalDistribution : UnivariateContinuousDistribution, IFittableDistribution<double, EmpiricalOptions>, IFittable<double, EmpiricalOptions>, IFittable<double>, IFittableDistribution<double>, IDistribution<double>, IDistribution, ICloneable, ISampleableDistribution<double>, IRandomNumberGenerator<double>
The EmpiricalDistribution type exposes the following members.
Name  Description  

EmpiricalDistribution(Double) 
Creates a new Empirical Distribution from the data samples.
 
EmpiricalDistribution(Double, Double) 
Creates a new Empirical Distribution from the data samples.
 
EmpiricalDistribution(Double, Double) 
Creates a new Empirical Distribution from the data samples.
 
EmpiricalDistribution(Double, Int32) 
Creates a new Empirical Distribution from the data samples.
 
EmpiricalDistribution(Double, Double, Double) 
Creates a new Empirical Distribution from the data samples.
 
EmpiricalDistribution(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.
 
Entropy 
Gets the entropy for this distribution.
(Overrides UnivariateContinuousDistributionEntropy.)  
Length 
Gets the total number of samples in this distribution.
 
Mean 
Gets the mean for this distribution.
(Overrides UnivariateContinuousDistributionMean.)  
Median 
Gets the median for this distribution.
(Inherited from UnivariateContinuousDistribution.)  
Mode 
Gets the mode for this distribution.
(Overrides UnivariateContinuousDistributionMode.)  
Quartiles 
Gets the Quartiles for this distribution.
(Inherited from UnivariateContinuousDistribution.)  
Samples 
Gets the samples giving this empirical distribution.
 
Smoothing 
Gets the bandwidth smoothing parameter
used in the kernel density estimation.
 
StandardDeviation 
Gets the Standard Deviation (the square root of
the variance) for the current distribution.
(Inherited from UnivariateContinuousDistribution.)  
Support 
Gets the support interval for this distribution.
(Overrides UnivariateContinuousDistributionSupport.)  
Variance 
Gets the variance for this distribution.
(Overrides UnivariateContinuousDistributionVariance.)  
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 UnivariateContinuousDistribution.)  
CumulativeHazardFunction 
Gets the cumulative hazard function for this
distribution evaluated at point x.
(Inherited from UnivariateContinuousDistribution.)  
DistributionFunction(Double) 
Gets the cumulative distribution function (cdf) for
this distribution evaluated at point x.
(Overrides UnivariateContinuousDistributionDistributionFunction(Double).)  
DistributionFunction(Double, Double) 
Gets the cumulative distribution function (cdf) for this
distribution in the semiclosed interval (a; b] given as
P(a < X ≤ b).
(Inherited from UnivariateContinuousDistribution.)  
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 UnivariateContinuousDistribution.)  
Fit(Double, IFittingOptions) 
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateContinuousDistribution.)  
Fit(Double, Double) 
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateContinuousDistribution.)  
Fit(Double, Int32) 
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateContinuousDistribution.)  
Fit(Double, Double, EmpiricalOptions) 
Fits the underlying distribution to a given set of observations.
 
Fit(Double, Double, IFittingOptions) 
Fits the underlying distribution to a given set of observations.
(Overrides UnivariateContinuousDistributionFit(Double, Double, IFittingOptions).)  
Fit(Double, Int32, EmpiricalOptions) 
Fits the underlying distribution to a given set of observations.
 
Fit(Double, Int32, IFittingOptions) 
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateContinuousDistribution.)  
Generate 
Generates a random observation from the current distribution.
(Overrides UnivariateContinuousDistributionGenerate.)  
Generate(Int32) 
Generates a random vector of observations from the current distribution.
(Inherited from UnivariateContinuousDistribution.)  
Generate(Int32, Double) 
Generates a random vector of observations from the current distribution.
(Overrides UnivariateContinuousDistributionGenerate(Int32, Double).)  
GetHashCode  Serves as the default hash function. (Inherited from Object.)  
GetRange 
Gets the distribution range within a given percentile.
(Inherited from UnivariateContinuousDistribution.)  
GetType  Gets the Type of the current instance. (Inherited from Object.)  
HazardFunction 
Gets the hazard function, also known as the failure rate or
the conditional failure density function for this distribution
evaluated at point x.
(Inherited from UnivariateContinuousDistribution.)  
InverseDistributionFunction 
Gets the inverse of the cumulative distribution function (icdf) for
this distribution evaluated at probability p. This function
is also known as the Quantile function.
(Inherited from UnivariateContinuousDistribution.)  
LogCumulativeHazardFunction 
Gets the log of the cumulative hazard function for this
distribution evaluated at point x.
(Inherited from UnivariateContinuousDistribution.)  
LogProbabilityDensityFunction 
Gets the logprobability density function (pdf) for
this distribution evaluated at point x.
(Inherited from UnivariateContinuousDistribution.)  
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.
(Overrides UnivariateContinuousDistributionProbabilityDensityFunction(Double).)  
QuantileDensityFunction 
Gets the first derivative of the
inverse distribution function (icdf) for this distribution evaluated
at probability p.
(Inherited from UnivariateContinuousDistribution.)  
SmoothingRule(Double) 
Gets the default estimative of the smoothing parameter.
 
SmoothingRule(Double, Double) 
Gets the default estimative of the smoothing parameter.
 
SmoothingRule(Double, Int32) 
Gets the default estimative of the smoothing parameter.
 
SmoothingRule(Double, Double, Int32) 
Gets the default estimative of the smoothing parameter.
 
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.)  
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.)  
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 Matrix.) 
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 following example shows how to build an empirical distribution directly from a sample:
// Consider the following univariate samples double[] samples = { 5, 5, 1, 4, 1, 2, 2, 3, 3, 3, 4, 3, 3, 3, 4, 3, 2, 3 }; // Create a nonparametric, empirical distribution using those samples: EmpiricalDistribution distribution = new EmpiricalDistribution(samples); // Common measures double mean = distribution.Mean; // 3 double median = distribution.Median; // 2.9999993064186787 double var = distribution.Variance; // 1.2941176470588236 // Cumulative distribution function double cdf = distribution.DistributionFunction(x: 4.2); // 0.88888888888888884 double ccdf = distribution.ComplementaryDistributionFunction(x: 4.2); //0.11111111111111116 double icdf = distribution.InverseDistributionFunction(p: cdf); // 4.1999999999999993 // Probability density functions double pdf = distribution.ProbabilityDensityFunction(x: 4.2); // 0.15552784414141974 double lpdf = distribution.LogProbabilityDensityFunction(x: 4.2); // 1.8609305013898356 // Hazard (failure rate) functions double hf = distribution.HazardFunction(x: 4.2); // 1.3997505972727771 double chf = distribution.CumulativeHazardFunction(x: 4.2); // 2.1972245773362191 // Automatically estimated smooth parameter (gamma) double smoothing = distribution.Smoothing; // 1.9144923416414432 // String representation string str = distribution.ToString(CultureInfo.InvariantCulture); // Fn(x; S)