Last change
on this file was 1, checked in by Wouter Pasman, 6 years ago |
Initial import : Genius 9.0.0
|
File size:
929 bytes
|
Line | |
---|
1 | package agents.anac.y2013.GAgent;
|
---|
2 |
|
---|
3 | public class Probability {
|
---|
4 |
|
---|
5 | public double mean;
|
---|
6 | public double widthUtil;
|
---|
7 | public double variance;
|
---|
8 | public int itemNum;
|
---|
9 |
|
---|
10 | private double sumRatio;
|
---|
11 | private double sumRatio2;
|
---|
12 |
|
---|
13 |
|
---|
14 | public Probability(double w) {
|
---|
15 | sumRatio = 0;
|
---|
16 | sumRatio2 = 0;
|
---|
17 | mean = 0D;
|
---|
18 | widthUtil = w;
|
---|
19 | variance = 0D;
|
---|
20 | itemNum = 0;
|
---|
21 | }
|
---|
22 | private void calMean(double ratio){
|
---|
23 | sumRatio += ratio;
|
---|
24 | mean = sumRatio / itemNum;
|
---|
25 | }
|
---|
26 |
|
---|
27 | private double calVar(double ratio){
|
---|
28 | sumRatio2 += ratio * ratio;
|
---|
29 | variance = sumRatio2 / itemNum - mean*mean;
|
---|
30 | return variance;
|
---|
31 | }
|
---|
32 |
|
---|
33 | private double getRatio(double util){
|
---|
34 | return util / widthUtil;
|
---|
35 | }
|
---|
36 |
|
---|
37 | public double getM(double diff){
|
---|
38 | itemNum++;
|
---|
39 | double ra = getRatio(diff);
|
---|
40 | calMean(ra);
|
---|
41 | return mean;
|
---|
42 | }
|
---|
43 | public double getVar(double diff){
|
---|
44 | itemNum++;
|
---|
45 | double ra = getRatio(diff);
|
---|
46 | calMean(diff);
|
---|
47 | variance = calVar(ra);
|
---|
48 | return mean*100000*variance*widthUtil;
|
---|
49 | }
|
---|
50 |
|
---|
51 |
|
---|
52 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.