toString prints seed.
@@ -20,14 +20,17 @@ public class MersenneTwister implements RandomNumberGenerator1D, Serializable {
private static final long serialVersionUID = -1827470318370174186L;
+ private final Long seed;
private final org.apache.commons.math3.random.MersenneTwister mersenneTwister;
public MersenneTwister(final long seed) {
+ this.seed = seed;
mersenneTwister = new org.apache.commons.math3.random.MersenneTwister(seed);
}
public MersenneTwister() {
- mersenneTwister = new org.apache.commons.math3.random.MersenneTwister();
+ this.seed = System.currentTimeMillis() + System.identityHashCode(this); // This is the same way as MT would create the seed.
+ mersenneTwister = new org.apache.commons.math3.random.MersenneTwister(seed);
}
/**
@@ -46,4 +49,10 @@ public class MersenneTwister implements RandomNumberGenerator1D, Serializable {
public double nextDoubleFast() {
return mersenneTwister.nextDouble();
}
+
+ @Override
+ public String toString() {
+ return "MersenneTwister [seed=" + seed + "]";
+ }
+
}
