Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package scripts.ReactionTime;
- import java.util.Random;
- public class Generator {
- public static void main(String[] args) {
- for (int a = 0; a < 100000; a++) {
- System.out.println(getBankOpenReaction());
- }
- }
- private static Random r = new Random();
- public static double nextGaussian(double avg, double dev) {
- return avg + r.nextGaussian() * dev;
- }
- public static double nextExponential(double clustering) {
- return -Math.log(1 - r.nextDouble()) / clustering;
- }
- public static double nextExGaussian(double avg, double dev, double clustering) {
- return nextGaussian(avg, dev) + nextExponential(clustering);
- }
- public static double nextUniform(double minimum, double maximum) {
- return r.nextDouble() * (maximum - minimum) + minimum;
- }
- /**
- * Utility function to generate a reaction time within a given set of parameters.
- * @param avg The average (mu) of the data.
- * @param dev The standard deviation (sigma) of the data.
- * @param clustering How tightly clustered the data will be about the mean. Smaller values reduce clustering, while larger ones increase it.
- * @param leftSkew The strength at which the values will be skewed to the left.
- * @param minimum The minimum in the range of values that can be produced.
- * @param maximum The maximum in the range of values that can be produced.
- */
- public static double nextReactionTime(double avg, double dev, double clustering, double leftSkew, double minimum, double maximum) {
- double next = r.nextDouble();
- if (next < leftSkew) {
- return nextUniform(minimum, maximum);
- }
- double exGaussian = nextExGaussian(avg, dev, clustering);
- if (exGaussian < minimum || exGaussian > maximum) {
- return nextReactionTime(avg, dev, clustering, leftSkew, minimum, maximum);
- }
- return exGaussian;
- }
- // REACTION TIME GENERATORS
- public static long getBankOpenReaction() {
- return Math.round(nextReactionTime(275, 70, 0.007, 0.0025, 100, 1700));
- }
- }
Add Comment
Please, Sign In to add comment