Location : Home > Languages > Perl > Package
Title : Statistics::GammaDistribution
Toolbox Logo

名称

 Statistics::GammaDistribution - ガンマ分布


概要

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);

メソッド

$gamma = Statistics::GammaDistribution->new();

 パラメータは不要。

$variate = $gamma->rand( SCALE );

 本関数はガンマ分布に従う乱数を返す。分布関数は

p(x) dx = {1 \over \Gamma(a) b^a} x^{a-1} e^{-x/b} dx
for x > 0.

である。ただし、a は次数で b はスケールである。 パラメータとして設定されない限り SCALE は 1.0 とみなされる。

$gamma->get/set_order( ORDER );

 分布の次数を取得/設定する。次数は0よりも大きくなくてはならない。

@theta = $gamma->dirichlet_dist( ALPHA );

 実数の K サイズの配列(すべて0より大きい)をとり、ディルケ分布(Dirichlet distribution)に従う K サイズの乱数の配列を返す。分布関数は以下の通りである。

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

ただし theta_i >= 0 かつ alpha_i >= 0 とする。正規化因子 Z は以下の式で与えられる。

Z = {\prod_{i=1}^K \Gamma(\alpha_i)} / {\Gamma( \sum_{i=1}^K \alpha_i)}

 乱数変数は order=alpha_i, scale=1 のガンマ分布から K 個の値を抽出し、正規化することで生成する。詳しくは A.M. Law, W.D. Kelton, Simulation Modeling and Analysis (1991) を見よ。


著者

 Nigel Wetters Gourlay, <nwetters@cpan.org>


著作権

 Copyright (c) 2003-06, Nigel Wetters Gourlay. 無保証である。

 本プログラムはフリーソフトウェアであり、Free Software Foundation により公開された GNU General Public License (version 2 またはユーザの考えに基づきそれ以降のバージョン)の条件の下で修正/再配布してもよい。

Toolbox Logo
Updated : 2007/07/28