Trying to generate simulated reaction times following a reverse exponential distribution, with I guess the most common value being 273ms.
I'm writing in java and cannot use any imported libraries, can anyone help?
mine for a poission dist looks like:
public static int getPossion(int lambda) {
int sum = 0;
int n =-1;
while (sum < lambda) {
n += 1;
sum -= Math.log(random());
}
return n;
}
public static int getPoissonRandom(double mean) {
Random r = new Random();
double L = Math.exp(-mean);
int k = 0;
double p = 1.0;
do {
p = p * r.nextDouble();
k++;
} while (p > L);
return k - 1;
}
I'm writing in java and cannot use any imported libraries, can anyone help?
mine for a poission dist looks like:
public static int getPossion(int lambda) {
int sum = 0;
int n =-1;
while (sum < lambda) {
n += 1;
sum -= Math.log(random());
}
return n;
}
public static int getPoissonRandom(double mean) {
Random r = new Random();
double L = Math.exp(-mean);
int k = 0;
double p = 1.0;
do {
p = p * r.nextDouble();
k++;
} while (p > L);
return k - 1;
}
