1 public class Estimator {
10 public Estimator(int stages) {
15 this.probtable = new double[31];
17 this.probtable[i++] = 0.5000;
18 this.probtable[i++] = 0.5398;
19 this.probtable[i++] = 0.5793;
20 this.probtable[i++] = 0.6179;
21 this.probtable[i++] = 0.6554;
22 this.probtable[i++] = 0.6915;
23 this.probtable[i++] = 0.7257;
24 this.probtable[i++] = 0.7580;
25 this.probtable[i++] = 0.7881;
26 this.probtable[i++] = 0.8159;
27 this.probtable[i++] = 0.8413;
28 this.probtable[i++] = 0.8643;
29 this.probtable[i++] = 0.8849;
30 this.probtable[i++] = 0.9032;
31 this.probtable[i++] = 0.9192;
32 this.probtable[i++] = 0.9332;
33 this.probtable[i++] = 0.9452;
34 this.probtable[i++] = 0.9554;
35 this.probtable[i++] = 0.9641;
36 this.probtable[i++] = 0.9713;
37 this.probtable[i++] = 0.9772;
38 this.probtable[i++] = 0.9821;
39 this.probtable[i++] = 0.9861;
40 this.probtable[i++] = 0.9893;
41 this.probtable[i++] = 0.9918;
42 this.probtable[i++] = 0.9938;
43 this.probtable[i++] = 0.9953;
44 this.probtable[i++] = 0.9965;
45 this.probtable[i++] = 0.9974;
46 this.probtable[i++] = 0.9981;
47 this.probtable[i++] = 0.9987;
50 public boolean estimate(int time, double variance2) {
51 System.printI(0xff30);
53 this.variance += variance2;
55 System.printI(0xff31);
56 System.printI(this.stages);
57 System.printI(this.time);
58 System.printI((int)this.variance);
59 if(this.stages == 0) {
60 System.printI(0xff32);
61 //System.printString("variance2: " + (int)(this.variance*100) + "(/100); ");
62 this.variance = Math.sqrt(this.variance);
63 //System.printString("variance: " + (int)(this.variance*100) + "(/100)\n");
66 System.printI(0xff33);
70 public double getProbability(int x, int y) {
78 double prob = prob(r) - prob(l);
82 private double prob(int s) {
83 int tmp = (int)((s - this.time) * 10 / this.variance);
84 //System.printString(tmp + "\n");
85 int abs = (int)Math.abs(tmp);
87 if(abs > this.probtable.length - 1) {
90 prob = this.probtable[abs];
99 public int getTime() {
103 public double getVariance() {
104 return this.variance;