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

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

public class JSimUniformStream
extends java.lang.Object

A stream generating random real values with a uniform distribution on a given interval. The bounds of the interval 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 uniform 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 a
          The lower bound of the interval from which random numbers are generated.
private  double b
          The upper bound of the interval from which random numbers are generated.
protected  java.util.Random stream
          An internal stream from which random numbers are taken and modified.
 
Constructor Summary
JSimUniformStream(double a, double b)
          Creates a new stream generating random real values from a given interval.
JSimUniformStream(double a, double b, long seed)
          Creates a new stream generating random real values from a given interval.
 
Method Summary
 double getA()
          Returns the lower bound of the interval.
 double getB()
          Returns the upper bound of the interval.
 double getNext()
          Returns a randomly generated real value from the interval specified on this stream's construction.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

stream

protected java.util.Random stream
An internal stream from which random numbers are taken and modified.


a

private double a
The lower bound of the interval from which random numbers are generated.


b

private double b
The upper bound of the interval from which random numbers are generated.

Constructor Detail

JSimUniformStream

public JSimUniformStream(double a,
                         double b)
                  throws JSimInvalidParametersException
Creates a new stream generating random real values from a given interval. A pseudo-randomly generated seed will be used.

Parameters:
a - The lower bound of the interval.
b - The upper bound of the interval.
Throws:
JSimInvalidParametersException - This exception is thrown out if a is not less than b.

JSimUniformStream

public JSimUniformStream(double a,
                         double b,
                         long seed)
                  throws JSimInvalidParametersException
Creates a new stream generating random real values from a given interval. The seed given as the third argument will be used.

Parameters:
a - The lower bound of the interval.
b - The upper bound of the interval.
seed - A seed that will initialize the generator.
Throws:
JSimInvalidParametersException - This exception is thrown out if a is not less than b.
Method Detail

getNext

public double getNext()
Returns a randomly generated real value from the interval specified on this stream's construction.

Returns:
A random real value from the given interval.

getA

public double getA()
Returns the lower bound of the interval.

Returns:
The lower bound of the interval.

getB

public double getB()
Returns the upper bound of the interval.

Returns:
The upper bound of the interval.


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