BernoulliDistribution Class |
Namespace: Accord.Statistics.Distributions.Univariate
[SerializableAttribute] public class BernoulliDistribution : UnivariateDiscreteDistribution, IFittableDistribution<double, IFittingOptions>, IFittable<double, IFittingOptions>, IFittable<double>, IFittableDistribution<double>, IDistribution<double>, IDistribution, ICloneable, ISampleableDistribution<int>, IDistribution<int>, IRandomNumberGenerator<int>, IUnivariateDistribution<double>, IUnivariateDistribution
The BernoulliDistribution type exposes the following members.
Name | Description | |
---|---|---|
BernoulliDistribution |
Creates a new Bernoulli distribution.
| |
BernoulliDistribution(Double) |
Creates a new Bernoulli distribution.
|
Name | Description | |
---|---|---|
Entropy |
Gets the entropy for this distribution.
(Overrides UnivariateDiscreteDistributionEntropy.) | |
Mean |
Gets the mean for this distribution.
(Overrides UnivariateDiscreteDistributionMean.) | |
Median |
Gets the median for this distribution.
(Overrides UnivariateDiscreteDistributionMedian.) | |
Mode |
Gets the mode for this distribution.
(Overrides UnivariateDiscreteDistributionMode.) | |
Quartiles |
Gets the Quartiles for this distribution.
(Inherited from UnivariateDiscreteDistribution.) | |
StandardDeviation |
Gets the Standard Deviation (the square root of
the variance) for the current distribution.
(Inherited from UnivariateDiscreteDistribution.) | |
Support |
Gets the support interval for this distribution.
(Overrides UnivariateDiscreteDistributionSupport.) | |
Variance |
Gets the variance for this distribution.
(Overrides UnivariateDiscreteDistributionVariance.) |
Name | Description | |
---|---|---|
BaseDistributionFunction |
Computes the cumulative distribution function by summing the outputs of the ProbabilityMassFunction(Int32)
for all elements in the distribution domain. Note that this method should not be used in case there is a more
efficient formula for computing the CDF of a distribution.
(Inherited from UnivariateDiscreteDistribution.) | |
BaseInverseDistributionFunction |
Gets the inverse of the cumulative distribution function (icdf) for
this distribution evaluated at probability p using a numerical
approximation based on binary search.
(Inherited from UnivariateDiscreteDistribution.) | |
Clone |
Creates a new object that is a copy of the current instance.
(Overrides DistributionBaseClone.) | |
ComplementaryDistributionFunction(Int32) |
Gets P(X > k) the complementary cumulative distribution function
(ccdf) for this distribution evaluated at point k.
This function is also known as the Survival function.
(Inherited from UnivariateDiscreteDistribution.) | |
ComplementaryDistributionFunction(Int32, Boolean) |
Gets the complementary cumulative distribution function
(ccdf) for this distribution evaluated at point k.
This function is also known as the Survival function.
(Inherited from UnivariateDiscreteDistribution.) | |
CumulativeHazardFunction |
Gets the cumulative hazard function for this
distribution evaluated at point x.
(Inherited from UnivariateDiscreteDistribution.) | |
DistributionFunction(Int32) |
Gets P(X ≤ k), the cumulative distribution function
(cdf) for this distribution evaluated at point k.
(Inherited from UnivariateDiscreteDistribution.) | |
DistributionFunction(Int32, Boolean) |
Gets P(X ≤ k) or P(X < k), the cumulative distribution function
(cdf) for this distribution evaluated at point k, depending
on the value of the inclusive parameter.
(Inherited from UnivariateDiscreteDistribution.) | |
DistributionFunction(Int32, Int32) |
Gets the cumulative distribution function (cdf) for this
distribution in the semi-closed interval (a; b] given as
P(a < X ≤ b).
(Inherited from UnivariateDiscreteDistribution.) | |
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 UnivariateDiscreteDistribution.) | |
Fit(Int32) |
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateDiscreteDistribution.) | |
Fit(Double, IFittingOptions) |
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateDiscreteDistribution.) | |
Fit(Double, Double) |
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateDiscreteDistribution.) | |
Fit(Double, Int32) |
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateDiscreteDistribution.) | |
Fit(Int32, IFittingOptions) |
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateDiscreteDistribution.) | |
Fit(Double, Double, IFittingOptions) |
Fits the underlying distribution to a given set of observations.
(Overrides UnivariateDiscreteDistributionFit(Double, Double, IFittingOptions).) | |
Fit(Double, Int32, IFittingOptions) |
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateDiscreteDistribution.) | |
Fit(Int32, Double, IFittingOptions) |
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateDiscreteDistribution.) | |
Fit(Int32, Int32, IFittingOptions) |
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateDiscreteDistribution.) | |
Generate |
Generates a random observation from the current distribution.
(Inherited from UnivariateDiscreteDistribution.) | |
Generate(Random) |
Generates a random observation from the current distribution.
(Overrides UnivariateDiscreteDistributionGenerate(Random).) | |
Generate(Int32) |
Generates a random vector of observations from the current distribution.
(Inherited from UnivariateDiscreteDistribution.) | |
Generate(Int32, Double) |
Generates a random vector of observations from the current distribution.
(Inherited from UnivariateDiscreteDistribution.) | |
Generate(Int32, Int32) |
Generates a random vector of observations from the current distribution.
(Inherited from UnivariateDiscreteDistribution.) | |
Generate(Int32, Random) |
Generates a random vector of observations from the current distribution.
(Inherited from UnivariateDiscreteDistribution.) | |
Generate(Int32, Int32, Random) |
Generates a random vector of observations from the current distribution.
(Overrides UnivariateDiscreteDistributionGenerate(Int32, Int32, Random).) | |
Generate(Int32, Double, Random) |
Generates a random vector of observations from the current distribution.
(Inherited from UnivariateDiscreteDistribution.) | |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetRange |
Gets the distribution range within a given percentile.
(Inherited from UnivariateDiscreteDistribution.) | |
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 UnivariateDiscreteDistribution.) | |
InnerComplementaryDistributionFunction |
Gets P(X > k) the complementary cumulative distribution function
(ccdf) for this distribution evaluated at point k.
This function is also known as the Survival function.
(Overrides UnivariateDiscreteDistributionInnerComplementaryDistributionFunction(Int32).) | |
InnerDistributionFunction |
Gets the cumulative distribution function (cdf) for
this distribution evaluated at point k.
(Overrides UnivariateDiscreteDistributionInnerDistributionFunction(Int32).) | |
InnerInverseDistributionFunction |
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.
(Overrides UnivariateDiscreteDistributionInnerInverseDistributionFunction(Double).) | |
InnerLogProbabilityMassFunction |
Gets the log-probability mass function (pmf) for
this distribution evaluated at point x.
(Overrides UnivariateDiscreteDistributionInnerLogProbabilityMassFunction(Int32).) | |
InnerProbabilityMassFunction |
Gets the probability mass function (pmf) for
this distribution evaluated at point x.
(Overrides UnivariateDiscreteDistributionInnerProbabilityMassFunction(Int32).) | |
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 UnivariateDiscreteDistribution.) | |
LogCumulativeHazardFunction |
Gets the log-cumulative hazard function for this
distribution evaluated at point x.
(Inherited from UnivariateDiscreteDistribution.) | |
LogProbabilityMassFunction |
Gets the log-probability mass function (pmf) for
this distribution evaluated at point x.
(Inherited from UnivariateDiscreteDistribution.) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
ProbabilityMassFunction |
Gets the probability mass function (pmf) for
this distribution evaluated at point x.
(Inherited from UnivariateDiscreteDistribution.) | |
QuantileDensityFunction |
Gets the first derivative of the
inverse distribution function (icdf) for this distribution evaluated
at probability p.
(Inherited from UnivariateDiscreteDistribution.) | |
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.) |
The Bernoulli distribution is a distribution for a single binary variable x E {0,1}, representing, for example, the flipping of a coin. It is governed by a single continuous parameter representing the probability of an observation to be equal to 1.
References:
// Create a distribution with probability 0.42 var bern = new BernoulliDistribution(mean: 0.42); // Common measures double mean = bern.Mean; // 0.42 double median = bern.Median; // 0.0 double var = bern.Variance; // 0.2436 double mode = bern.Mode; // 0.0 // Probability mass functions double pdf = bern.ProbabilityMassFunction(k: 1); // 0.42 double lpdf = bern.LogProbabilityMassFunction(k: 0); // -0.54472717544167193 // Cumulative distribution functions double cdf = bern.DistributionFunction(k: 0); // 0.58 double ccdf = bern.ComplementaryDistributionFunction(k: 0); // 0.42 // Quantile functions int icdf0 = bern.InverseDistributionFunction(p: 0.57); // 0 int icdf1 = bern.InverseDistributionFunction(p: 0.59); // 1 // Hazard / failure rate functions double hf = bern.HazardFunction(x: 0); // 1.3809523809523814 double chf = bern.CumulativeHazardFunction(x: 0); // 0.86750056770472328 // String representation string str = bern.ToString(CultureInfo.InvariantCulture); // "Bernoulli(x; p = 0.42, q = 0.58)"