make everything use same random number generator

This commit is contained in:
2022-02-23 09:29:21 -06:00
parent 08699ce8ce
commit 74ffbfd8ac
4 changed files with 18 additions and 17 deletions

View File

@@ -1,11 +1,13 @@
import java.util.Random;
//main class. For choosing interface type and caching file data
public class BiGpairSEQ {
private static final Random rand = new Random();
private static CellSample cellSampleInMemory = null;
private static String cellFilename = null;
private static Plate plateInMemory = null;
private static String plateFilename = null;
private static GraphWithMapData graphInMemory = null;
private static String graphFilename = null;
@@ -20,6 +22,10 @@ public class BiGpairSEQ {
}
}
public static Random getRand() {
return rand;
}
public static CellSample getCellSampleInMemory() {
return cellSampleInMemory;
}

View File

@@ -4,10 +4,6 @@ import java.math.MathContext;
public abstract class Equations {
public static int getRandomInt(int min, int max) {
return (int) ((Math.random() * (max - min)) + min);
}
//pValue calculation as described in original pairSEQ paper.
//Included for comparison with original results.
//Not used by BiGpairSEQ for matching.

View File

@@ -1,17 +1,15 @@
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.InputMismatchException;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
//
public class InteractiveInterface {
final static Scanner sc = new Scanner(System.in);
static int input;
static boolean quit = false;
private static final Random rand = BiGpairSEQ.getRand();
private static final Scanner sc = new Scanner(System.in);
private static int input;
private static boolean quit = false;
public static void startInteractive() {
@@ -169,10 +167,11 @@ public class InteractiveInterface {
if(maxPop < minPop) {
throw new InputMismatchException("Max well population must be greater than min well population");
}
populations = new Integer[numSections];
for(int i = 0; i < numSections; i++) {
populations[i] = Equations.getRandomInt(minPop, maxPop);
}
//maximum should be inclusive, so need to add one to max of randomly generated values
populations = (Integer[]) rand.ints(minPop, maxPop + 1)
.limit(numSections)
.boxed()
.toArray();
System.out.print("Populations: ");
System.out.println(Arrays.toString(populations));
}

View File

@@ -10,7 +10,7 @@ import java.util.*;
public class Plate {
private String sourceFile;
private List<List<Integer[]>> wells;
private Random rand = new Random();
private final Random rand = BiGpairSEQ.getRand();
private int size;
private double error;
private Integer[] populations;