package umontreal.iro.lecuyer.randvar;
import umontreal.iro.lecuyer.rng.*;
import umontreal.iro.lecuyer.probdist.*;


/**
 * This class implements random variate generators for the 
 * Fisher F distribution with n and m
 * degrees of freedom, where n and m are positive integers.
 * The density function of this distribution is
 * 
 * 

*
* f (x) = Γ((n + m)/2)nn/2mm/2/[Γ(n/2)Γ(m/2)]x(n-2)/2/(m + nx)(n+m)/2,         for x > 0. *

* */ public class FisherFGen extends RandomVariateGen { protected int n = -1; protected int m = -1; /** * Creates a Fisher F random variate generator with * n and m degrees of freedom, using stream s. * */ public FisherFGen (RandomStream s, int n, int m) { super (s, new FisherFDist(n, m)); setParams (n, m); } /** * Creates a new generator for the distribution dist, * using stream s. * */ public FisherFGen (RandomStream s, FisherFDist dist) { super (s, dist); if (dist != null) setParams (dist.getN(), dist.getM()); } /** * Generates a variate from the Fisher F distribution with * n and m degrees of freedom, using stream s. * */ public static double nextDouble (RandomStream s, int n, int m) { return FisherFDist.inverseF (n, m, 15, s.nextDouble()); } /** * Returns the parameter n of this object. * */ public int getN() { return n; } /** * Returns the parameter p of this object. * * */ public int getM() { return m; } /** * Sets the parameters n and m of this object. * */ protected void setParams (int n, int m) { if (m <= 0) throw new IllegalArgumentException ("m <= 0"); if (n <= 0) throw new IllegalArgumentException ("n <= 0"); this.m = m; this.n = n; } }

Ads help maintain this website.