-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTesting.java
62 lines (52 loc) · 1.77 KB
/
Testing.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import java.util.Arrays;
import java.util.Random;
/*
TODO: generalizar vector shuffle: max 64, pasar actual length como param
*/
class Testing {
public static void main(String[] args) {
Testing t = new Testing();
Random r = new Random();
// GaussianGenerator gen = new GaussianGenerator()
// for (int i = 0; i < 500000; i++) {
// //System.out.println("LifeTime: "+t.getLifeTime(r));
// System.out.println(t.getNextForkTime(r));
// }
int[] vector = {1,2,3,4,5,6,7,8,9,10};
int[] shuff = Testing.RandomizeArray(vector);
System.out.println(Arrays.toString(shuff));
}
public int getLifeTime(Random r) {
double val = r.nextGaussian() * 15 ;
int lt = Math.abs((int) Math.round(val)) + 1;
lt = lt < 64 ? lt : 64;
return (lt);
}
public double getLifeTimeD(Random r) {
double val = r.nextGaussian();
int lt = Math.abs((int) Math.round(val));
return (lt);
}
public int getNextForkTime(Random r) {
double val = r.nextGaussian() * 90;
int next = (int)val+65;
while(next < 1) {
val = r.nextGaussian() * 90;
next = (int)val+65;
}
return (next);
}
public static int[] RandomizeArray(int[] array){
Random rgen = new Random(); // Random number generator
for (int i=0; i<array.length; i++) {
int randomPosition = rgen.nextInt(array.length);
int temp = array[i];
array[i] = array[randomPosition];
array[randomPosition] = temp;
}
return array;
}
// public int getUnif(Random r) {
// return r.nextInt(1)
// }
}