cz.zcu.fav.kiv.jsim.random
Class JSimGaussianStream

java.lang.Object
  extended by cz.zcu.fav.kiv.jsim.random.JSimGaussianStream

public class JSimGaussianStream
extends java.lang.Object

A stream generating random real values with a Gaussian (aka normal) distribution with given mu and sigma. The two parameters are set by the user when the stream is constructed. An initial seed can be specified, which allows you to generate the same sequence of random values several times. A complex description of Gaussian (normal) distribution can be found at Wolfram Research Math World pages.

Since:
J-Sim version 0.3.0
Version:
J-Sim version 0.6.0
Author:
Jarda KAČER

Field Summary
private  double mu
          The mu parameter of the distribution, equal to the mean value.
private  double sigma
          The sigma parameter of the distribution, equal to the square root of the variance.
protected  JSimUniformStream stream
          An internal stream from which random numbers are taken and modified.
 
Constructor Summary
JSimGaussianStream(double mu, double sigma)
          Creates a new stream generating random real values with Gaussian distribution.
JSimGaussianStream(double mu, double sigma, long seed)
          Creates a new stream generating random real values with Gaussian distribution.
 
Method Summary
 double getMu()
          Returns the mu parameter of the distribution.
 double getNext()
          Returns a randomly generated real value having Gaussian distribution with the given mu and sigma parameters.
 double getSigma()
          Returns the sigma parameter of the distribution.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

stream

protected JSimUniformStream stream
An internal stream from which random numbers are taken and modified. Because we need the stream to generate values with a uniform distribution from <0,1>, JSimUniformStream is used instead the classic Java Random.


mu

private double mu
The mu parameter of the distribution, equal to the mean value.


sigma

private double sigma
The sigma parameter of the distribution, equal to the square root of the variance.

Constructor Detail

JSimGaussianStream

public JSimGaussianStream(double mu,
                          double sigma)
                   throws JSimInvalidParametersException
Creates a new stream generating random real values with Gaussian distribution. A pseudo-randomly generated seed will be used.

Parameters:
mu - The mu parameter of the distribution, equal to the mean value.
sigma - The sigma parameter of the distribution, equal to the square root of the variance.
Throws:
JSimInvalidParametersException - This exception is thrown out if sigma is less than 0.

JSimGaussianStream

public JSimGaussianStream(double mu,
                          double sigma,
                          long seed)
                   throws JSimInvalidParametersException
Creates a new stream generating random real values with Gaussian distribution. The seed given as the third argument will be used.

Parameters:
mu - The mu parameter of the distribution, equal to the mean value.
sigma - The sigma parameter of the distribution, equal to the square root of the variance.
seed - A seed that will initialize the generator.
Throws:
JSimInvalidParametersException - This exception is thrown out if sigma is less than 0.
Method Detail

getNext

public double getNext()
Returns a randomly generated real value having Gaussian distribution with the given mu and sigma parameters.

Returns:
A random real value with Gaussian distribution.

getMu

public double getMu()
Returns the mu parameter of the distribution.

Returns:
The mu parameter of the distribution.

getSigma

public double getSigma()
Returns the sigma parameter of the distribution.

Returns:
The sigma parameter of the distribution.


Copyright © 2000-2006 University of West Bohemia. Licensed under the Academic Free License v. 2.1. Build date 20060812.