All Downloads are FREE. Search and download functionalities are using the official Maven repository.

umontreal.iro.lecuyer.randvar.StudentNoncentralGen Maven / Gradle / Ivy

Go to download

SSJ is a Java library for stochastic simulation, developed under the direction of Pierre L'Ecuyer, in the Département d'Informatique et de Recherche Opérationnelle (DIRO), at the Université de Montréal. It provides facilities for generating uniform and nonuniform random variates, computing different measures related to probability distributions, performing goodness-of-fit tests, applying quasi-Monte Carlo methods, collecting (elementary) statistics, and programming discrete-event simulations with both events and processes.

The newest version!


/*
 * Class:        StudentNoncentralGen
 * Description:  random variate generator for the noncentral Student-t distribution
 * Environment:  Java
 * Software:     SSJ 
 * Copyright (C) 2001  Pierre L'Ecuyer and Université de Montréal
 * Organization: DIRO, Université de Montréal
 * @author       
 * @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 random variate generators for the 
 * noncentral Student-t distribution with n > 0 degrees of freedom and
 * noncentrality parameter δ. If X is distributed according to a 
 * normal distribution with mean  δ and variance 1, and Y (statistically
 * independent of X) is distributed according to a chi-square distribution 
 * with n degrees of freedom, then
 * 
 * 

*
* T ' = X/(Y/n)1/2 *

* has a noncentral t-distribution with n degrees of freedom and * noncentrality parameter δ. * */ public class StudentNoncentralGen extends RandomVariateGen { private NormalGen normgen; private ChiSquareGen chigen; private int n; // degrees of freedom of chi-square public double nextDouble() { double x = normgen.nextDouble(); double y = chigen.nextDouble(); return x / Math.sqrt(y/n); } /** * Creates a noncentral-t random variate generator * using normal generator ngen and chi-square generator cgen. * */ public StudentNoncentralGen (NormalGen ngen, ChiSquareGen cgen) { super (null, null); setNormalGen (ngen); setChiSquareGen (cgen); } /** * Sets the normal generator to ngen. * */ public void setNormalGen (NormalGen ngen) { if (1.0 != ngen.getSigma()) throw new IllegalArgumentException (" variance of normal must be 1"); normgen = ngen; } /** * Sets the chi-square generator to cgen. * */ public void setChiSquareGen (ChiSquareGen cgen) { chigen = cgen; n = cgen.getN(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy