edu.cornell.lassp.houle.RngPack
Class RandomSeedable
- java.lang.Object
-
- edu.cornell.lassp.houle.RngPack.RandomElement
-
- edu.cornell.lassp.houle.RngPack.RandomSeedable
-
- All Implemented Interfaces:
- java.lang.Cloneable
public abstract class RandomSeedable extends RandomElement
RandomSeedableis an abstract class that extends theRandomElementclass to include the ability to automatically generate a validlongseed from the clock. Thus it provides a consistent interface for seeding interchangable generators. It is reccomended that aRandomSeedablehave a constructor that takes alongfor a seed. For example, if you write a generator calledReallyRandom, you want to be able to dolong seed=ReallyRandom.ClockSeed(); RandomSeedable e=new ReallyRandom(seed);
this makes it convenient to keep a copy of the seed in case you want to restart the generator with the same seed some time in the future.If one is going to use a long to generate a smaller seed by taking
Clockseed()modulus another number, we reccomend that you use a prime number; this ensures that the generator would have the maximum "period" if it were started at regular issues, for instance, by a batch job. SeeRanmarfor an example.Source code is available.
-
-
Constructor Summary
Constructors Constructor and Description RandomSeedable()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static longClockSeed()Return a long integer seed calculated from the date.static longClockSeed(java.util.Date d)Return a long integer seed given a date
-
-
-
Method Detail
-
ClockSeed
public static long ClockSeed(java.util.Date d)
Return a long integer seed given a date- Parameters:
d- a date- Returns:
- a long integer seed
-
ClockSeed
public static long ClockSeed()
Return a long integer seed calculated from the date. Equivalent toClockSeed(new Date());- Returns:
- a long integer seed
-
-
DMelt 3.0 © DataMelt by jWork.ORG