Database Reference
In-Depth Information
A draw can be generated from this distribution using the inverse CDF
method used to draw from the exponential distribution:
protected double nextGammaF (double a) {
double L = Math. sqrt (2*a - 1);
double u = rng.nextDouble();
return a*Math. pow (u/(1-u), 1/L);
}
The draw from the enveloping distribution is then used as the draw from the
target distribution with a probability of g(x)/f(x). Otherwise another draw is
attempted until this condition is met:
protected double nextGamma(double k,double p) {
[[OPEN-LW-CODE80]] while(true) {
double x = nextGammaF(k);
if(rng.nextDouble() <= gamma_f(x,k)/
Distributions. dgamma (x, k, 1)) {
return x/p;
}
}[[CLOSE-LW-CODE80]]
}
Note that the closer the ratio g(x)/f(x) is to 1, the better the performance
of the algorithm. Figure 9.1 shows the density for the gamma distribution
with different shape parameters. The dotted line shows the density of the
envelope distribution for the rejection sampling method for the same shape
parameter. The choice of f(x) in this case is fairly good, as shown in Figure
9.1 , but it will be inefficient to sample from the tails of the gamma
distribution. Other methods have been developed to deal with this
inefficiency.
 
Search WWH ::




Custom Search