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

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

public class JSimDrawStream
extends java.lang.Object

A stream generating random boolean values. The probability that true is generated is determined by the user when the stream is constructed. An initial seed can be specified, which allows you to generate the same sequence of boolean random values several times.

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

Field Summary
private  double probability
          The probability that true will be generated each time getNext() is invoked.
protected  java.util.Random stream
          An internal stream from which random numbers are taken and modified.
 
Constructor Summary
JSimDrawStream(double probability)
          Creates a new stream generating random boolean values.
JSimDrawStream(double probability, long seed)
          Creates a new stream generating random boolean values.
 
Method Summary
 boolean getNext()
          Returns a randomly generated boolean value.
 double getProbability()
          Returns the probability that true is generated by getNext().
 
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.


probability

private double probability
The probability that true will be generated each time getNext() is invoked.

Constructor Detail

JSimDrawStream

public JSimDrawStream(double probability)
               throws JSimInvalidParametersException
Creates a new stream generating random boolean values. A pseudo-randomly generated seed will be used.

Parameters:
probability - The probability that true will be returned by getNext().
Throws:
JSimInvalidParametersException - This exception is thrown out if the given probability is out of the interval <0,1>.

JSimDrawStream

public JSimDrawStream(double probability,
                      long seed)
               throws JSimInvalidParametersException
Creates a new stream generating random boolean values. The seed given as the second argument will be used.

Parameters:
probability - The probability that true will be returned by getNext().
seed - A seed that will initialize the generator.
Throws:
JSimInvalidParametersException - This exception is thrown out if the given probability is out of the interval <0,1>.
Method Detail

getNext

public boolean getNext()
Returns a randomly generated boolean value. The probability that true is returned is equal to the probability specified by the user when the stream is created.

Returns:
A random boolean value.

getProbability

public double getProbability()
Returns the probability that true is generated by getNext().

Returns:
The probability that true is generated by getNext().


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