NAME
Statistics::GammaDistribution - represents a gamma distribution
SYNOPSIS
use Statistics::GammaDistribution;
my $g = Statistics::GammaDistribution->new();
$g->set_order(8.5);
print $g->rand(1.0);
my @alpha = (0.5,4.5,20.5,6.5,1.5,0.5);
my @theta = $g->dirichlet_dist(@alpha);
METHODS
- $gamma = Statistics::GammaDistribution->new();
-
No parameters necessary.
- $variate = $gamma->rand( SCALE );
-
This function returns a random variate from the gamma distribution. The distribution function is,
p(x) dx = {1 \over \Gamma(a) b^a} x^{a-1} e^{-x/b} dx for x > 0.
Where a is the order and b is the scale. Unless supplied as a parameter, SCALE is assumed to be 1.0 if not supplied.
- $gamma->get/set_order( ORDER );
-
Gets/sets the order of the distribution. Order must be greater than zero.
- @theta = $gamma->dirichlet_dist( ALPHA );
-
Takes a K-sized array of real numbers (all greater than zero), and returns a K-sized array containing random variates from a Dirichlet distribution. The distribution function is
p(\theta_1, ..., \theta_K) d\theta_1 ... d\theta_K = (1/Z) \prod_{i=1}^K \theta_i^{\alpha_i - 1} \delta(1 -\sum_{i=1}^K \theta_i) d\theta_1 ... d\theta_K for theta_i >= 0 and alpha_i >= 0. The normalization factor Z is Z = {\prod_{i=1}^K \Gamma(\alpha_i)} / {\Gamma( \sum_{i=1}^K \alpha_i)}
The random variates are generated by sampling K values from gamma distributions with parameters order=alpha_i, scale=1, and renormalizing. See A.M. Law, W.D. Kelton, Simulation Modeling and Analysis (1991).
AUTHOR
Nigel Wetters Gourlay <nwetters@cpan.org>
COPYRIGHT
Copyright (c) 2003-06, Nigel Wetters Gourlay. NO WARRANTY.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.