![]() | NORSYS SOFTWARE © 2011 | NETICA API | JAVA   VERSION   5.02  |
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--norsys.netica.RandomGenerator
A class that manages the generation of random numbers.
Constructor Summary | |
RandomGenerator(java.lang.String seed,
Environ env,
java.lang.String options)
Creates a new object to generate pseudo-random numbers, or control Netica's internal random number generation. |
Method Summary | |
void |
finalize()
Removes the this RandomGenerator object and frees all its resources (e.g., memory). |
double |
generateRandomNumbers(double[] results,
int num,
java.lang.String options)
Generates num random numbers using this randomGenerator and puts them in the array result, returning the first one. |
Environ |
getEnviron()
Returns this RandomGenerator's environment. |
java.lang.String |
getState(java.lang.String options)
Returns a string that can be used as a seed to generateRandomNumbers to create a RandomGenerator that will produce exactly the same pseudo-random numbers as this randGen. |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public RandomGenerator ( |
| ) throws NeticaException |
For ease in debugging and tracing, Netica API behaviour is always deterministic (unless non-determinism comes from multiple threads not synchronized), unless "Nondeterministic" is passed as options.
Netica API can be made to appear non-deterministic (e.g. to generate different sequences of cases with generateRandomCase) by passing in a "random" value for seed.
seed can either be a positive integer (as a string), or the result returned by getState.
options should either be null or the string "Nondeterministic". If it is the latter, seed is ignored and the random sequence will be nondeterministic.
When you are finished with the random generator object, free the resources it uses by calling DeleteRandomGen.
Parameters:
String | seed | A definition of the algorithm state of the random generator. | ||
Environ | env | The environment that will contain this generator. | ||
String | options | Controls behavior of the generator. |
finalize | To free the RandomGenerator when done with it. | |
getState | To obtain a seed value. | |
generateRandomNumbers | Use the RandomGenerator to make random numbers. | |
Net.generateRandomCase | Use it to control simulation. | |
Net.setRandomGenerator | Associate a RandomGenerator with a net. |
Method Detail |
public void finalize ( ) throws NeticaException |
You must not call this on a randomGenerator that was passed to setRandomGenerator.
You must not try to use or delete randomGenerator after calling this.
It is okay if randomGenerator is null (then no action is taken).
Version:
RandomGenerator | To create a new RandomGenerator. |
See RandomGenerator.
finalize
in class java.lang.Object
public Environ getEnviron ( ) |
public String getState ( |
| ) throws NeticaException |
So you can save the state of a random generator to later make an equivalent generator.
The results returned are only valid until the next operation using this randGen, so you should duplicate the string returned.
The string returned will always be a null terminated C string of printing ascii characters, so it can be easily printed to a file.
Pass null for options; it is only for future expansion.
Parameters:
String | options | For future expandability. Pass null for now. |
RandomGenerator | Create a new RandomGenerator with the value returned. |
See RandomGenerator.
public double generateRandomNumbers ( |
| ) throws NeticaException |
The numbers will be between 0 (inclusive) and 1 (exclusive), that is, from the interval [0,1).
results should be an array with enough room to store the required numbers; it may be null if you are just using the number returned.
This randomGenerator will be left in a state to generate further random numbers, or it can be passed to any Netica API function that takes a RandomGenerator.
Pass null for options; it is only for future expansion.
Parameters:
double[] | results | An array with enough room to store the required numbers; it may be null. | ||
int | num | The quantity of numbers to generate. | ||
String | options | Controls behavior of the generation. |
RandomGenerator | To create a new RandomGenerator. |
See RandomGenerator.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |