1 import java.util.Random;
13 public Stage(int id) {
16 this.samplings = new int[10];
17 for(int i = 0; i < this.samplings.length; ++i) {
18 this.samplings[i] = 0;
28 public void sampling() {
30 int tmp = samplings[samplings.length];
33 Random r = new Random(ID);
35 for(int i = 0; i < this.samplings.length; ++i) {
37 tint = r.nextInt()%50;
39 this.samplings[i] = tint;
40 //System./*out.print*/printString(tint + "; ");
43 //for(int i = 0; i < this.samplings.length; ++i) {
44 // this.samplings[i] = tint + i;
45 //System.printString(tint + "; ");
47 //System.printString("\n");//out.println();
50 public void estimate() {
52 int tmp = samplings[samplings.length];
55 int highest = this.samplings[0];
56 int lowest = this.samplings[0];
57 int sum = this.samplings[0];
58 for(int i = 1; i < this.samplings.length; ++i) {
59 int temp = this.samplings[i];
62 } else if(temp < lowest) {
67 sum = sum - highest - lowest;
68 int ordinary = sum / (this.samplings.length - 2);
69 this.optime = lowest;;
70 this.petime = highest;
71 this.nortime = ordinary;
72 this.time = (this.optime + 4 * this.nortime + this.petime) / 6;
73 this.variance2 = (double)(this.optime - this.petime) * (double)(this.optime - this.petime) / 36.0;
74 //System.out.println("Op time: " + this.optime + "; Nor time: " + this.nortime + "; Pe time: " + this.petime + "; variance2: " + (int)(this.variance2*100) + "(/100)");
77 public int getAntTime() {
81 public double getAntVariance2() {
82 return this.variance2;