Click or drag to resize
Accord.NET (logo)

GeneralizedBetaDistribution Class

The 4-parameter Beta distribution.
Inheritance Hierarchy
SystemObject
  Accord.Statistics.DistributionsDistributionBase
    Accord.Statistics.Distributions.UnivariateUnivariateContinuousDistribution
      Accord.Statistics.Distributions.UnivariateGeneralizedBetaDistribution

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

The GeneralizedBetaDistribution type exposes the following members.

Constructors
  NameDescription
Public methodGeneralizedBetaDistribution(Double, Double)
Constructs a Beta distribution defined in the interval (0,1) with the given parameters α and β.
Public methodGeneralizedBetaDistribution(Double, Double, Double, Double)
Constructs a Beta distribution defined in the interval (a, b) with parameters α, β, a and b.
Top
Properties
  NameDescription
Public propertyAlpha
Gets the shape parameter α (alpha)
Public propertyBeta
Gets the shape parameter β (beta).
Public propertyEntropy
Gets the entropy for this distribution.
(Overrides UnivariateContinuousDistributionEntropy.)
Public propertyMax
Gets the maximum value B.
Public propertyMean
Gets the mean for this distribution, defined as (a + 4 * m + 6 * b).
(Overrides UnivariateContinuousDistributionMean.)
Public propertyMedian
Gets the median for this distribution.
(Inherited from UnivariateContinuousDistribution.)
Public propertyMin
Gets the minimum value A.
Public propertyMode
Gets the mode for this distribution.
(Overrides UnivariateContinuousDistributionMode.)
Public propertyQuartiles
Gets the Quartiles for this distribution.
(Inherited from UnivariateContinuousDistribution.)
Public propertyStandardDeviation
Gets the Standard Deviation (the square root of the variance) for the current distribution.
(Inherited from UnivariateContinuousDistribution.)
Public propertySupport
Gets the distribution support, defined as (Min, Max).
(Overrides UnivariateContinuousDistributionSupport.)
Public propertyVariance
Gets the variance for this distribution, defined as ((b - a) / (k+2))²
(Overrides UnivariateContinuousDistributionVariance.)
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 UnivariateContinuousDistribution.)
Public methodCumulativeHazardFunction
Gets the cumulative hazard function for this distribution evaluated at point x.
(Inherited from UnivariateContinuousDistribution.)
Public methodDistributionFunction(Double)
Gets the cumulative distribution function (cdf) for this distribution evaluated at point x.
(Inherited from UnivariateContinuousDistribution.)
Public methodDistributionFunction(Double, Double)
Gets the cumulative distribution function (cdf) for this distribution in the semi-closed interval (a; b] given as P(a < X ≤ b).
(Inherited from UnivariateContinuousDistribution.)
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodStatic memberEstimate(Double, Int32, Int32)
Estimates a new Beta distribution from a set of observations.
Public methodStatic memberEstimate(Double, Int32, Int32, GeneralizedBetaOptions)
Estimates a new Beta distribution from a set of observations.
Public methodStatic memberEstimate(Double, Int32, Int32, Double)
Estimates a new Beta distribution from a set of weighted observations.
Public methodStatic memberEstimate(Double, Int32, Int32, Double, GeneralizedBetaOptions)
Estimates a new Beta distribution from a set of weighted observations.
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 methodCode exampleFit(Double)
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateContinuousDistribution.)
Public methodCode exampleFit(Double, IFittingOptions)
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateContinuousDistribution.)
Public methodCode exampleFit(Double, Double)
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateContinuousDistribution.)
Public methodCode exampleFit(Double, Int32)
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateContinuousDistribution.)
Public methodFit(Double, Double, GeneralizedBetaOptions)
Fits the underlying distribution to a given set of observations.
Public methodFit(Double, Double, IFittingOptions)
Fits the underlying distribution to a given set of observations.
(Overrides UnivariateContinuousDistributionFit(Double, Double, IFittingOptions).)
Public methodFit(Double, Int32, GeneralizedBetaOptions)
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 UnivariateContinuousDistributionFit(Double, Int32, IFittingOptions).)
Public methodGenerate
Generates a random observation from the current distribution.
(Inherited from UnivariateContinuousDistribution.)
Public methodGenerate(Random)
Generates a random observation from the current distribution.
(Overrides UnivariateContinuousDistributionGenerate(Random).)
Public methodGenerate(Int32)
Generates a random vector of observations from the current distribution.
(Inherited from UnivariateContinuousDistribution.)
Public methodGenerate(Int32, Double)
Generates a random vector of observations from the current distribution.
(Inherited from UnivariateContinuousDistribution.)
Public methodGenerate(Int32, Random)
Generates a random vector of observations from the current distribution.
(Inherited from UnivariateContinuousDistribution.)
Public methodGenerate(Int32, Double, Random)
Generates a random vector of observations from the current distribution.
(Overrides UnivariateContinuousDistributionGenerate(Int32, Double, Random).)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetRange
Gets the distribution range within a given percentile.
(Inherited from UnivariateContinuousDistribution.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodStatic memberGolenkoGinzburg
Constructs a BetaPERT distribution defined in the interval (a, b) using Golenko-Ginzburg observation that the mode is often at 2/3 of the guessed interval.
Public methodHazardFunction
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.)
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 UnivariateContinuousDistribution.)
Protected methodInnerDistributionFunction
Gets the cumulative distribution function (cdf) for this distribution evaluated at point x.
(Overrides UnivariateContinuousDistributionInnerDistributionFunction(Double).)
Protected methodInnerInverseDistributionFunction
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 UnivariateContinuousDistributionInnerInverseDistributionFunction(Double).)
Protected methodInnerLogProbabilityDensityFunction
Gets the log-probability density function (pdf) for this distribution evaluated at point x.
(Overrides UnivariateContinuousDistributionInnerLogProbabilityDensityFunction(Double).)
Protected methodInnerProbabilityDensityFunction
Gets the probability density function (pdf) for this distribution evaluated at point x.
(Overrides UnivariateContinuousDistributionInnerProbabilityDensityFunction(Double).)
Public methodInverseDistributionFunction
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.)
Public methodLogCumulativeHazardFunction
Gets the log of the cumulative hazard function for this distribution evaluated at point x.
(Inherited from UnivariateContinuousDistribution.)
Public methodLogProbabilityDensityFunction
Gets the log-probability density function (pdf) for this distribution evaluated at point x.
(Inherited from UnivariateContinuousDistribution.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodStatic memberPert(Double, Double, Double)
Constructs a BetaPERT distribution defined in the interval (a, b) using usual PERT estimation for the parameters a, b, mode and λ.
Public methodStatic memberPert(Double, Double, Double, Double)
Constructs a BetaPERT distribution defined in the interval (a, b) using usual PERT estimation for the parameters a, b, mode and λ.
Public methodProbabilityDensityFunction
Gets the probability density function (pdf) for this distribution evaluated at point x.
(Inherited from UnivariateContinuousDistribution.)
Public methodQuantileDensityFunction
Gets the first derivative of the inverse distribution function (icdf) for this distribution evaluated at probability p.
(Inherited from UnivariateContinuousDistribution.)
Public methodStatic memberRandom(Double, Double, Double, Double)
Generates a random observation from a Beta distribution with the given parameters.
Public methodStatic memberRandom(Double, Double, Double, Double, Int32)
Generates a random vector of observations from the Beta distribution with the given parameters.
Public methodStatic memberRandom(Double, Double, Double, Double, Random)
Generates a random observation from a Beta distribution with the given parameters.
Public methodStatic memberRandom(Double, Double, Double, Double, Int32, Double)
Generates a random vector of observations from the Beta distribution with the given parameters.
Public methodStatic memberRandom(Double, Double, Double, Double, Int32, Random)
Generates a random vector of observations from the Beta distribution with the given parameters.
Public methodStatic memberRandom(Double, Double, Double, Double, Int32, Double, Random)
Generates a random vector of observations from the Beta distribution with the given parameters.
Public methodStatic memberStandard
Constructs a standard Beta distribution defined in the interval (0, 1) based on the number of successed and trials for an experiment.
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).)
Public methodStatic memberVose(Double, Double, Double)
Constructs a BetaPERT distribution defined in the interval (a, b) using Vose's PERT estimation for the parameters a, b, mode and λ.
Public methodStatic memberVose(Double, Double, Double, Double)
Constructs a BetaPERT distribution defined in the interval (a, b) using Vose's PERT estimation for the parameters a, b, mode and λ.
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

The generalized beta distribution is a family of continuous probability distributions defined on any interval (min, max) parameterized by two positive shape parameters and two real location parameters, typically denoted by α, β, a and b. The beta distribution can be suited to the statistical modeling of proportions in applications where values of proportions equal to 0 or 1 do not occur. One theoretical case where the beta distribution arises is as the distribution of the ratio formed by one random variable having a Gamma distribution divided by the sum of it and another independent random variable also having a Gamma distribution with the same scale parameter (but possibly different shape parameter).

References:

Examples

Note: Simpler examples are also available at the BetaDistribution page.

The following example shows how to create a simpler 2-parameter Beta distribution and compute some of its properties and measures.

double alpha = 0.42;
double beta = 1.57;

var betaDistribution = new GeneralizedBetaDistribution(alpha, beta);

double mean = betaDistribution.Mean; // 0.21105527638190955
double median = betaDistribution.Median; // 0.11577706212908731
double var = betaDistribution.Variance; // 0.055689279830523512
double mode = betaDistribution.Mode;    // 57.999999999999957

double chf = betaDistribution.CumulativeHazardFunction(x: 0.27); // 1.1828193992944409
double cdf = betaDistribution.DistributionFunction(x: 0.27); // 0.69358638272337991
double pdf = betaDistribution.ProbabilityDensityFunction(x: 0.27); // 0.94644031936694828
double lpdf = betaDistribution.LogProbabilityDensityFunction(x: 0.27); // -0.055047364344046057
double hf = betaDistribution.HazardFunction(x: 0.27); // 3.0887671630877072
double ccdf = betaDistribution.ComplementaryDistributionFunction(x: 0.27); // 0.30641361727662009
double icdf = betaDistribution.InverseDistributionFunction(p: cdf); // 0.26999999068687469

string str = betaDistribution.ToString(System.Globalization.CultureInfo.InvariantCulture); // "B(x; α = 0.42, β = 1.57)

The following example shows how to create a 4-parameter (Generalized) Beta distribution and compute some of its properties and measures.

double alpha = 0.42;
double beta = 1.57;

var betaDistribution = new GeneralizedBetaDistribution(alpha, beta);

double mean = betaDistribution.Mean; // 0.21105527638190955
double median = betaDistribution.Median; // 0.11577706212908731
double var = betaDistribution.Variance; // 0.055689279830523512
double mode = betaDistribution.Mode;    // 57.999999999999957

double chf = betaDistribution.CumulativeHazardFunction(x: 0.27); // 1.1828193992944409
double cdf = betaDistribution.DistributionFunction(x: 0.27); // 0.69358638272337991
double pdf = betaDistribution.ProbabilityDensityFunction(x: 0.27); // 0.94644031936694828
double lpdf = betaDistribution.LogProbabilityDensityFunction(x: 0.27); // -0.055047364344046057
double hf = betaDistribution.HazardFunction(x: 0.27); // 3.0887671630877072
double ccdf = betaDistribution.ComplementaryDistributionFunction(x: 0.27); // 0.30641361727662009
double icdf = betaDistribution.InverseDistributionFunction(p: cdf); // 0.26999999068687469

string str = betaDistribution.ToString(System.Globalization.CultureInfo.InvariantCulture); // "B(x; α = 0.42, β = 1.57)

The following example shows how to create a 4-parameter Beta distribution with a three-point estimate using PERT.

// Create a Beta from a minimum, maximum and most likely value
var b = GeneralizedBetaDistribution.Pert(min: 1, max: 3, mode: 2);

double mean = b.Mean;     // 2
double median = b.Median; // 2
double mode = b.Mode;     // 2
double var = b.Variance;  // 0.071428571428571425

The following example shows how to create a 4-parameter Beta distribution with a three-point estimate using Vose's modification for PERT.

// Create a Beta from a minimum, maximum and most likely value
var b = GeneralizedBetaDistribution.Vose(min: 1, max: 3, mode: 1.42);

double mean = b.Mean;     // 1.6133333333333333
double median = b.Median; // 1.5727889200146494
double mode = b.Mode;     // 1.4471823077804513
double var = b.Variance;  // 0.055555555555555546

The next example shows how to generate 1000 new samples from a Beta distribution:

// Using the distribution's parameters
double[] samples = GeneralizedBetaDistribution.Random(alpha: 2, beta: 3, min: 0, max: 1, samples: 1000);

// Using an existing distribution
var b = new GeneralizedBetaDistribution(alpha: 1, beta: 2);
double[] new_samples = b.Generate(1000);

And finally, how to estimate the parameters of a Beta distribution from a set of observations, using either the Method-of-moments or the Maximum Likelihood Estimate.

// First we will be drawing 100000 observations from a 4-parameter 
//   Beta distribution with α = 2, β = 3, min = 10 and max = 15:

double[] samples = GeneralizedBetaDistribution.Random(alpha: 2, beta: 3, min: 10, max: 15, samples: 100000);

// We can estimate a distribution with the known max and min
var B = GeneralizedBetaDistribution.Estimate(samples, 10, 15);

// We can explicitly ask for a Method-of-moments estimation
var mm = GeneralizedBetaDistribution.Estimate(samples, 10, 15,
    new GeneralizedBetaOptions { Method = BetaEstimationMethod.Moments });

// or explicitly ask for the Maximum Likelihood estimation
var mle = GeneralizedBetaDistribution.Estimate(samples, 10, 15,
    new GeneralizedBetaOptions { Method = BetaEstimationMethod.MaximumLikelihood });
See Also