Demos-3/Notes/howTo-UseModelParameters-RNG.txt ---------------------------------------------- The ModelParameters class provides a simple, uniform way to start and generate samples from a single RNG. This RNG is seeded using the ModelParameters "seed" parameter if it is provided, or it uses a number from the system clock. In either case, the startReportFile() method, also provided by the ModelParameters class, will write the seed used to the top of any report files, so that the run can be reproduced. Note: these RNG's are built on uchicago.src.sim.util.Random from RePast, which in turn is built on the CERN Colt RNGs. To use the RNG facilities provided by ModelParameters: - In the buildModel() method, before building any model-specific objects, call buildModelStart(); This will check the "seed" parameter and start the RNG. - There are some predefined and pre-initialized methods to generate a few common random variates. These are all static (class) methods, so they can be called from anywhere in the program using the "Model" class that extends the ModelParameters class. Uniform: static public int getUniformIntFromTo ( int low, int high ) returns an int from closed interval [low,high] static public double getUniformDoubleFromTo( double low, double high ) returns a double from open interval (low,high) static public double getNormalDouble ( double mean, double var ) returns a double from the gaussian with given mean and variance static public double getNormalDoubleProb ( double mean, double var ) returns a sample from a gaussian with the given mean,var *except* it keeps sampling until the value is in [0,1]. Thus 0 < mean < 1 is required, and a big variance could cause a lot of resampling. --------------------------- - To add additional distribution generators that use these same seeds: In the ModelParameters method resetRNGenerators ( ) use the seed parameter to get the distribution defined and initialized. - Add static methods to ModelParameters to provide the method calls you want based on that distribution. NOTE: be sure to fully qualify the reference to Random if there might be a conflict between the Java Random and the Repast Random classes. ----------------------------