SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
Anova.java
1package umontreal.ssj.mcqmctools.anova;
2
3// import umontreal.ssj.rng.RandomStream;
4// import umontreal.ssj.hups.RQMCPointSet;
5// import umontreal.ssj.mcqmctools.*;
6// import umontreal.ssj.mcqmctools.anova.*;
7
15public class Anova {
16
17 protected int maxOrder = Integer.MAX_VALUE;
18 protected int maxCoordinate = Integer.MAX_VALUE;
19
20 protected RandomIntegrator innerIntegrator;
21 protected Integrator outerIntegrator;
22
23 public Anova(Integrator outerIntegrator, RandomIntegrator innerIntegrator) {
24 this.outerIntegrator = outerIntegrator;
25 this.innerIntegrator = innerIntegrator;
26 }
27
28 public Anova() {
29 this(null, null);
30 }
31
39 public void setOuterIntegrator(Integrator integrator) {
40 this.outerIntegrator = integrator;
41 }
42
48 public void setInnerIntegrator(RandomIntegrator integrator) {
49 this.innerIntegrator = integrator;
50 }
51
56 public void setMaxCoordinate(int maxCoordinate) {
57 this.maxCoordinate = maxCoordinate;
58 }
59
64 public void setMaxOrder(int maxOrder) {
65 this.maxOrder = maxOrder;
66 }
67
75 return estimate(model, approxMean, null);
76 }
77
86 public AnovaVarianceCollector estimate(MonteCarloModelDoubleRQMC model, double approxMean, AnovaObserver observer) {
87
88 int dimension = Math.min(maxCoordinate + 1, model.getDimension());
89
91 varEstimator.setModel(model, approxMean);
92 varEstimator.setCoordinates(CoordinateSetLong.allCoordinates(dimension), maxOrder);
93 varEstimator.setIntegrator(innerIntegrator);
94
95 AnovaVarianceCollector varCollector = new AnovaVarianceCollector(varEstimator.getCoordinateSets());
96 if (observer != null)
97 varCollector.addObserver(observer);
98
99 outerIntegrator.integrate(varEstimator, varCollector);
100 varCollector.sort();
101
102 return varCollector;
103 }
104
105 @Override
106 public String toString() {
107 String s = "ANOVA";
108 if (maxCoordinate < Integer.MAX_VALUE)
109 s += " [maxCoordinate=" + maxCoordinate + "]";
110 if (maxOrder < Integer.MAX_VALUE)
111 s += " [maxOrder=" + maxOrder + "]";
112 if (outerIntegrator != null) {
113 s += umontreal.ssj.util.PrintfFormat.NEWLINE;
114 s += " Outer Integrator:";
115 s += umontreal.ssj.util.PrintfFormat.NEWLINE;
116 s += " " + outerIntegrator;
117 }
118 if (innerIntegrator != null) {
119 s += umontreal.ssj.util.PrintfFormat.NEWLINE;
120 s += " Inner Integrator:";
121 s += umontreal.ssj.util.PrintfFormat.NEWLINE;
122 s += " " + innerIntegrator;
123 }
124
125 return s;
126 }
127}
Extends ListOfTallies to collect ANOVA variances.
void addObserver(AnovaObserver observer)
Add an observer, which is notified when the ANOVA variance collector is updated.
List< CoordinateSet > getCoordinateSets()
Returns the list of coordinate sets under consideration.
void setIntegrator(RandomIntegrator integrator)
Sets the integrator.
void setCoordinates(List< CoordinateSet > coordSets)
Set the coordinate sets to consider to coordSets.
AnovaVarianceCollector estimate(MonteCarloModelDoubleRQMC model, double approxMean)
Produces multiple replicates of the ANOVA variance estimators.
Definition Anova.java:74
void setInnerIntegrator(RandomIntegrator integrator)
Sets the inner integrator which is used to generate one random estimation of the ANOVA variances at a...
Definition Anova.java:48
void setMaxCoordinate(int maxCoordinate)
Sets the maximum coordinate index to consider.
Definition Anova.java:56
void setMaxOrder(int maxOrder)
Sets the maximum projection order to consider.
Definition Anova.java:64
AnovaVarianceCollector estimate(MonteCarloModelDoubleRQMC model, double approxMean, AnovaObserver observer)
Produces multiple replicates of the ANOVA variance estimators.
Definition Anova.java:86
void setOuterIntegrator(Integrator integrator)
Sets the outer integrator from which provides a RandomStream to the randomization of the inner integr...
Definition Anova.java:39
Implementation of CoordinateSet using a long bit-mask internal representation.
static CoordinateSet allCoordinates(int dimension)
Returns a set of all coordinates in a space of dimension dimension.
An interface for a simple simulation model for which Monte Carlo (MC) or RQMC experiments are to be p...
int getDimension()
Returns the number of uniforms required to simulate this model.