HOME ›  AREAS OF EXPERTISE  #2 ›   Distribution Function ›  ~ Gamma Distribution

 "Distribution Functions" Gamma Distribution Method
 PARM X 0.375, --------------------------------------- 1.125, --------------------------------------- 1.875, --------------------------------------- 2.625, --------------------------------------- 3.375, --------------------------------------- 4.125, --------------------------------------- 4.875, --------------------------------------- 5.625, --------------------------------------- 6.375, --------------------------------------- 7.125, --------------------------------------- 7.875, --------------------------------------- 8.625, --------------------------------------- 9.375, --------------------------------------- 10.125, --------------------------------------- 10.875, --------------------------------------- 11.625, --------------------------------------- 12.375, --------------------------------------- 13.125, --------------------------------------- 13.875, --------------------------------------- 14.625, --------------------------------------- RANDOM DATA 100, --------------------------------------- 217, --------------------------------------- 287, --------------------------------------- 268, --------------------------------------- 225, --------------------------------------- 204, --------------------------------------- 156, --------------------------------------- 111, --------------------------------------- 120, --------------------------------------- 84, --------------------------------------- 69, --------------------------------------- 37, --------------------------------------- 34, --------------------------------------- 21, --------------------------------------- 18, --------------------------------------- 6, --------------------------------------- 9, --------------------------------------- 10, --------------------------------------- 4, --------------------------------------- 3, --------------------------------------- DENSITY DISTRIBUTION 122 --------------------------------------- 251 --------------------------------------- 287 --------------------------------------- 276 --------------------------------------- 244 --------------------------------------- 205 --------------------------------------- 166 --------------------------------------- 132 --------------------------------------- 103 --------------------------------------- 79 --------------------------------------- 60 --------------------------------------- 45 --------------------------------------- 34 --------------------------------------- 25 --------------------------------------- 18 --------------------------------------- 14 --------------------------------------- 10 --------------------------------------- 7 --------------------------------------- 5 --------------------------------------- 4 ---------------------------------------

 Results of Gamma Distribution
 Number of Points: Number of Bins: [ Initial Number of Bins: {20) ] [ Initial Number of Points: {2000} ]

IMPLEMENTATION
Gamma Distribution Method

The gamma distribution is a two-parameter family of continous probability distributions, representing the sum of exponentially-distributed random variables.

Probability Density Function

The probability density function of the gamma distribution can be expressed in terma of the gamma function:

 f(x;r,ç) = çr / T(r) * (xr-1 e-çx)

This function is defined in the parameter range r > 0,ç > 0, and x >0

Gamma Random Number Generator

If the parameter r is an integer, the random numbers from the gamma distribution can be calculated by the random numbers from uniform distribution, using the formula:

 Gamma(r,ç) = - 1/ç ∑i=1r ln Ui (0,1)

where Ui (0,1) is the random distribution defined in the range of [0,1]

Testing the Gamma Distribution Method

To test the Gamma Distribution method, a new static method has been added. The TestGammaDistribution() method has been written and executed. No additional code is shown. The user can change variables as desired.

For the test, two parameters were set:

 number of bins = 20; (nBins) number of points = 2000; (nPoints)

where the parameter (nBins) is the number of bins in the histogram and (nPoints) is the number of random points. A random array is created with the gamma distribution. A comparison is made between the histogram of random data and the theoretical probability density function of the gamma distribution. The number of random data points cannot be too small. Otherwise, the random distribution will deviate dramatically from the theoretical probability function.

Running this example generates the results shown above.

{
int nBins = t2;
int nPoints = t1;
double xmin = 0;
double xmin = 15;
double[] rand = RandomGenerators.NextGamma(2, 0.5, nPoints);
ArrayList aList = RandomGenerators.HistogramData(rand, xmin, xmax, nBins);
double[] xdata = new double[nBins];
double[] ydata = new double[nBins];
double[] ydistribution = new double[nBins];
for (int i = 0; i < nBins; i++)
{
xdata[i] = xmin + (i + 0.5) * (xmax - xmin) / nBins;
ydata[i] = (double)aList[i];
ydistribution[i] = DistributionFunctions.Gamma(xdata[i], 5);
}
double normalizeFactor = RandomGenerators.ArrayMax(ydata) / RandomGenerators.ArrayMax(ydistribution);
for (int i = 0; i < nBins; i++)
{
}
}

 Other Implementations...

 Object-Oriented Implementation Graphics and Animation Sample Applications Ore Extraction Optimization Vectors and Matrices Complex Numbers and Functions Ordinary Differential Equations - Euler Method Ordinary Differential Equations 2nd-Order Runge-Kutta Ordinary Differential Equations 4th-Order Runge-Kutta Higher Order Differential Equations Nonlinear Systems Numerical Integration Numerical Differentiation Function Evaluation

 Quotes

Math, Analysis,
expertise..."

EIGENVALUE
SOLUTIONS...

> Rayleigh-Quotient Method

> Cubic Spline Method

 Applied Mathematical Algorithms
 ComplexFunctions NonLinear Differentiation Integration
 About Us KMP Software Engineering is an independent multidisciplinary engineering consulting company specializing in mathematical algorithms.       (About Us) → Areas of Expertise SpecialFunctions VectorsMatrices OptimizationMethods ComplexNumbers Interpolation CurveFitting NonLinearSystems LinearEquations DistributionFunctions NumericalDifferentiation NumericalIntegration DifferentialEquations Smalltalk FiniteBoundary Eigenvalue Graphics UnderstandingMining MiningMastery MineralNews MineralCommodities MineralForum Crystallography Services NumericalModeling WebServices MainframeServices OutsourceServices LINKED IN MINE REVIEW(by G.Pacheco) Brand Login Contact