-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimulationRandom.java
More file actions
45 lines (34 loc) · 1.12 KB
/
Copy pathSimulationRandom.java
File metadata and controls
45 lines (34 loc) · 1.12 KB
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
import java.util.ArrayList;
import javax.swing.*;
import java.awt.image.BufferedImage;
import java.awt.*;
public class SimulationRandom extends AbstractSimulation
{
public static void main(String[] args){
ArrayList<Integer> data = simulateSamples(1000);
drawHistogram(200,data);
System.out.println("MEAN-> "+calculateMean(data));
System.out.println("DEVIATION-> "+calculateDeviation(data));
}
public static ArrayList<Integer> simulateSamples(int numSamples){
ArrayList<Integer> scores = new ArrayList();
RandomAI r = new RandomAI();
for (int i = 1; i <= numSamples; i++){
r.playGame();
scores.add(r.getScore());
}
return scores;
}
public static ArrayList<Integer> samplingDistribution(){
ArrayList<Integer> vals = new ArrayList();
for (int i = 0; i < 100; i++){
ArrayList<Integer> a = simulateSamples(1000);
int sum = 0;
for (int j : a){
sum += j;
}
vals.add(sum/a.size());
}
return vals;
}
}