SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
PartialVariance.java
1package umontreal.ssj.mcqmctools.anova;
2
3import umontreal.ssj.stat.Tally;
4
10public class PartialVariance extends Tally implements Comparable<PartialVariance> {
11
12 protected CoordinateSet coords;
13 protected Tally totalVar;
14
15 protected PartialVariance(CoordinateSet coords) {
16 this(coords, null);
17 }
18
19 protected PartialVariance(CoordinateSet coords, Tally totalVar) {
20 super("variance for coordinates " + coords);
21 this.coords = coords;
22 this.totalVar = totalVar;
23 }
24
30 return coords;
31 }
32
40 public double sensitivityIndex() {
41
42 if (totalVar == null)
43 throw new IllegalStateException(
44 "trying to access the sensitivity index without" + " a reference to the total variance");
45
46 return average() / totalVar.average();
47 }
48
54 public int compareTo(PartialVariance var) {
55 double v = average();
56 double vx = var.average();
57 return v > vx ? 1 : v < vx ? -1 : 0;
58 }
59
60 @Override
61 public String toString() {
62
63 String s = String.format("%30s: %9.4g", coords.toString(), average());
64
65 if (numberObs() > 1) {
66 double dvar = Math.sqrt(variance() / numberObs());
67 s += String.format(" ± %.2g", dvar);
68 }
69
70 if (totalVar != null) {
71 double varFrac = sensitivityIndex();
72 if (varFrac >= 0)
73 s += String.format(" (%.4g %%)", 100 * varFrac);
74 }
75
76 return s;
77 }
78}
int compareTo(PartialVariance var)
Returns 1, 0 or -1 if the current partial variance is larger, equal or smaller than the partial varia...
double sensitivityIndex()
Returns the sensitivity index (fraction of the total variance) of the coordinate set under considerat...
CoordinateSet getCoordinates()
Returns the coordinate set associated with the current partial variance.
double average()
Returns the average value of the observations since the last initialization.
Definition Tally.java:155
int numberObs()
Returns the number of observations given to this probe since its last initialization.
Definition Tally.java:143
double variance()
Returns the sample variance of the observations since the last initialization.
Definition Tally.java:174
Tally()
Constructs a new unnamed Tally statistical probe.
Definition Tally.java:66