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

umontreal.iro.lecuyer.randvar.ChiSquareNoncentralGen 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:        ChiSquareNoncentralGen
 * Description:  random variate generators for the noncentral chi square distribution
 * 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 random variate generators for the
 * noncentral chi square distribution with ν > 0 degrees of freedom
 * and noncentrality parameter 
 * λ > 0. See the definition in
 *  {@link umontreal.iro.lecuyer.probdist.ChiSquareNoncentralDist ChiSquareNoncentralDist}.
 * 
 */
public class ChiSquareNoncentralGen extends RandomVariateGen  {
   protected double nu = -1.0;
   protected double lambda = -1.0;




   /**
    * Creates a noncentral chi square  random variate generator
    *  with nu = ν > 0 degrees of freedom and noncentrality parameter 
    * lambda 
    * = λ > 0,
    *  using stream s.
    * 
    */
   public ChiSquareNoncentralGen (RandomStream s, double nu, double lambda)  {
      super (s, new ChiSquareNoncentralDist(nu, lambda));
      setParams (nu, lambda);
   }


   /**
    * Create a new generator for the distribution dist
    *     and stream s.
    * 
    */
   public ChiSquareNoncentralGen (RandomStream s,
                                  ChiSquareNoncentralDist dist)  {
      super (s, dist);
      if (dist != null)
         setParams (dist.getNu (), dist.getLambda());
   }


   /**
    * Generates a new variate from the noncentral chi square
    * distribution with nu = ν degrees of freedom and noncentrality 
    * parameter lambda = λ,
    *  using stream s.
    * 
    */
   public static double nextDouble (RandomStream s,
                                    double nu, double lambda)  {
      return ChiSquareNoncentralDist.inverseF (nu, lambda, s.nextDouble());
   }



   /**
    * Returns the value of  ν of this object.
    * 
    */
   public double getNu() {
      return nu;
   }


   /**
    * Returns the value of λ for this object.
    * 
    * 
    */
   public double getLambda() {
      return lambda;
   }


   /**
    * Sets the parameters ν = nu and λ =
    *   lambda of this object.
    * 
    */
   protected void setParams (double nu, double lambda) {
      if (nu <= 0.0)
         throw new IllegalArgumentException ("nu <= 0");
      if (lambda < 0.0)
         throw new IllegalArgumentException ("lambda < 0");
      this.nu = nu;
      this.lambda = lambda;
   }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy