SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
umontreal.ssj.randvar.StudentGen Class Reference

This class implements methods for generating random variates from the Student distribution with \(n>0\) degrees of freedom. More...

Inheritance diagram for umontreal.ssj.randvar.StudentGen:
umontreal.ssj.randvar.RandomVariateGen umontreal.ssj.randvar.StudentPolarGen

Public Member Functions

 StudentGen (RandomStream s, int n)
 Creates a Student random variate generator with \(n\) degrees of freedom, using stream s.
 StudentGen (RandomStream s, StudentDist dist)
 Creates a new generator for the Student distribution dist and stream s.
int getN ()
 Returns the value of \(n\) for this object.
Public Member Functions inherited from umontreal.ssj.randvar.RandomVariateGen
 RandomVariateGen (RandomStream s, Distribution dist)
 Creates a new random variate generator from the distribution dist, using stream s.
double nextDouble ()
 Generates a random number from the continuous distribution contained in this object.
void nextArrayOfDouble (double[] v, int start, int n)
 Generates n random numbers from the continuous distribution contained in this object.
double[] nextArrayOfDouble (int n)
 Generates n random numbers from the continuous distribution contained in this object, and returns them in a new array of size n.
RandomStream getStream ()
 Returns the umontreal.ssj.rng.RandomStream used by this generator.
void setStream (RandomStream stream)
 Sets the umontreal.ssj.rng.RandomStream used by this generator to stream.
Distribution getDistribution ()
 Returns the umontreal.ssj.probdist.Distribution used by this generator.
String toString ()
 Returns a String containing information about the current generator.

Static Public Member Functions

static double nextDouble (RandomStream s, int n)
 Generates a new variate from the Student distribution with \(n = \) n degrees of freedom, using stream s.

Detailed Description

This class implements methods for generating random variates from the Student distribution with \(n>0\) degrees of freedom.

Its density function is

\[ f (x) = \frac{\Gamma\left((n + 1)/2 \right)}{\Gamma(n/2) \sqrt{\pi n}} \left[1 + \frac{x^2}{n}\right]^{-(n+1)/2} \qquad\qquad\mbox{for } -\infty< x < \infty, \tag{fstudent} \]

where \(\Gamma(x)\) is the gamma function defined in ( Gamma ).

The nextDouble method simply calls inverseF on the distribution.

The following table gives the CPU time needed to generate \(10^7\) Student random variates using the different implementations available in SSJ. The second test (Q) was made with the inverse in umontreal.ssj.probdist.StudentDistQuick, while the first test was made with the inverse in umontreal.ssj.probdist.StudentDist. These tests were made on a machine with processor AMD Athlon 4000, running Red Hat Linux, with clock speed at 2400 MHz.

Generatortime in seconds
StudentGen22.4
StudentGen(Q) 6.5
StudentPolarGen 1.4

Definition at line 78 of file StudentGen.java.

Constructor & Destructor Documentation

◆ StudentGen() [1/2]

umontreal.ssj.randvar.StudentGen.StudentGen ( RandomStream s,
int n )

Creates a Student random variate generator with \(n\) degrees of freedom, using stream s.

Definition at line 85 of file StudentGen.java.

◆ StudentGen() [2/2]

umontreal.ssj.randvar.StudentGen.StudentGen ( RandomStream s,
StudentDist dist )

Creates a new generator for the Student distribution dist and stream s.

Definition at line 93 of file StudentGen.java.

Member Function Documentation

◆ getN()

int umontreal.ssj.randvar.StudentGen.getN ( )

Returns the value of \(n\) for this object.

Definition at line 111 of file StudentGen.java.

◆ nextDouble()

double umontreal.ssj.randvar.StudentGen.nextDouble ( RandomStream s,
int n )
static

Generates a new variate from the Student distribution with \(n = \) n degrees of freedom, using stream s.

Reimplemented in umontreal.ssj.randvar.StudentPolarGen.

Definition at line 104 of file StudentGen.java.


The documentation for this class was generated from the following file: