umontreal.iro.lecuyer.randvar.ChiSquareNoncentralPoisGen Maven / Gradle / Ivy
Show all versions of ssj Show documentation
/*
* Class: ChiSquareNoncentralPoisGen
* Description: noncentral chi square random variate generators using Poisson
and central chi square generators
* Environment: Java
* Software: SSJ
* Copyright (C) 2001 Pierre L'Ecuyer and Université de Montréal
* Organization: DIRO, Université de Montréal
* @author Richard Simard
* @since
* SSJ is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License (GPL) as published by the
* Free Software Foundation, either version 3 of the License, or
* any later version.
* SSJ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* A copy of the GNU General Public License is available at
GPL licence site.
*/
package umontreal.iro.lecuyer.randvar;
import umontreal.iro.lecuyer.rng.*;
import umontreal.iro.lecuyer.probdist.*;
/**
* This class implements noncentral chi square random variate generators
* using Poisson and central chi square generators. It uses the following algorithm:
* generate a random integer
* J∼Poisson(λ/2) from a Poisson
* distribution, generate a random real
* X∼Γ(j + ν/2, 1/2) from a
* gamma distribution, then return X.
* Here ν is the number of degrees of freedom and
* λ is the noncentrality parameter.
*
*
* To generate the Poisson variates, one
* uses tabulated inversion for
* λ < 10, and the acceptance complement
* method for
* λ >= 10, as in
* (see class {@link umontreal.iro.lecuyer.randvar.PoissonTIACGen PoissonTIACGen}).
* To generate the gamma variates, one
* uses acceptance-rejection for α < 1, and acceptance-complement
* for
* α >= 1, as proposed in
* (see class {@link umontreal.iro.lecuyer.randvar.GammaAcceptanceRejectionGen GammaAcceptanceRejectionGen}).
*
*/
public class ChiSquareNoncentralPoisGen extends ChiSquareNoncentralGen {
// protected RandomStream aux;
/**
* Creates a noncentral chi square random variate generator
* with ν = nu degrees of freedom and noncentrality parameter
* λ = lambda using stream stream, as described above.
*
*/
public ChiSquareNoncentralPoisGen (RandomStream stream,
double nu, double lambda) {
super (stream, null);
setParams (nu, lambda);
}
public double nextDouble() {
return poisGenere (stream, nu, lambda);
}
/**
* Generates a variate from the noncentral chi square
* distribution with
* parameters ν = nu and λ = lambda using
* stream stream, as described above.
*
*/
public static double nextDouble (RandomStream stream,
double nu, double lambda) {
return poisGenere (stream, nu, lambda);
}
//>>>>>>>>>>>>>>>>>>>> P R I V A T E S M E T H O D S <<<<<<<<<<<<<<<<<<<<
private static double poisGenere (RandomStream s, double nu, double lambda) {
int j = PoissonTIACGen.nextInt (s, 0.5*lambda);
return GammaAcceptanceRejectionGen.nextDouble (s, 0.5*nu + j, 0.5);
}
}