Percolation/Mean run density: Difference between revisions

m
Simplified code.
m (Altered a variable identifier.)
m (Simplified code.)
Line 774:
private static double runTest(double aProbability, int aLength, int aRunCount) {
double count = 0.0;
final int threshold = (int) ( aProbability * RANDOM_MAXIMUM );
for ( int run = 0; run < aRunCount; run++ ) {
int previousBit = 0;
int length = aLength;
while ( length-- > 0 ) {
int nextBit = ( random.nextIntnextDouble(RANDOM_MAXIMUM + 1.0) < thresholdaProbability ) ? 1 : 0;
if ( previousBit < nextBit ) {
count += 1.0;
Line 790 ⟶ 789:
 
private static ThreadLocalRandom random = ThreadLocalRandom.current();
private static final int RANDOM_MAXIMUM = Integer.MAX_VALUE - 1;
 
}
908

edits