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.4.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.
(Overrides UnivariateContinuousDistributionDistributionFunction(Double).)
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 methodFit(Double)
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateContinuousDistribution.)
Public methodFit(Double, IFittingOptions)
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateContinuousDistribution.)
Public methodFit(Double, Double)
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateContinuousDistribution.)
Public methodFit(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.
(Overrides UnivariateContinuousDistributionGenerate.)
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.
(Overrides UnivariateContinuousDistributionGenerate(Int32, Double).)
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.)
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.
(Overrides UnivariateContinuousDistributionInverseDistributionFunction(Double).)
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.
(Overrides UnivariateContinuousDistributionLogProbabilityDensityFunction(Double).)
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.
(Overrides UnivariateContinuousDistributionProbabilityDensityFunction(Double).)
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, Int32, Double)
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 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.)
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 Matrix.)
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 4-parameter Beta distribution and compute some of its properties and measures.

// Create a 4-parameter Beta distribution with the following parameters (α, β, a, b):
var beta = new GeneralizedBetaDistribution(alpha: 1.42, beta: 1.57, min: 1, max: 4.2);

double mean = beta.Mean;     // 2.5197324414715716
double median = beta.Median; // 2.4997705845160225
double var = beta.Variance;  // 0.19999664152943961
double mode = beta.Mode;     // 2.3575757575757574
double h = beta.Entropy;     // -0.050654548091478513

double cdf = beta.DistributionFunction(x: 2.27);           // 0.40828630817664596
double pdf = beta.ProbabilityDensityFunction(x: 2.27);     // 1.2766172921464953
double lpdf = beta.LogProbabilityDensityFunction(x: 2.27); // 0.2442138392176838

double chf = beta.CumulativeHazardFunction(x: 2.27);       // 0.5247323897609667
double hf = beta.HazardFunction(x: 2.27);                  // 2.1574915534109484

double ccdf = beta.ComplementaryDistributionFunction(x: 2.27); // 0.59171369182335409
double icdf = beta.InverseDistributionFunction(p: cdf);        // 2.27

string str = beta.ToString(); // B(x; α = 1.42, β = 1.57, min = 1, max = 4.2)

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.5197324414715716
double median = b.Median; // 2.4997705845160225
double var = b.Variance;  // 0.19999664152943961
double mode = b.Mode;     // 2.3575757575757574

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