SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
RQMCSampler.java
1package umontreal.ssj.mcqmctools.anova;
2
3import umontreal.ssj.stat.Tally;
4import umontreal.ssj.rng.RandomStream;
5import umontreal.ssj.hups.*;
6import umontreal.ssj.mcqmctools.*;
7
14public class RQMCSampler implements RandomSampler {
15
16 protected RQMCPointSet points;
17
18 public RQMCSampler(RQMCPointSet points, RandomStream stream) {
19 this.points = points;
20 setStream(stream);
21 }
22
23 public RQMCSampler(RQMCPointSet points) {
24 this.points = points;
25 }
26
32 return points;
33 }
34
37 return points.getRandomization().getStream();
38 }
39
41 public void setStream(RandomStream stream) {
42 points.getRandomization().setStream(stream);
43 }
44
47 return 1;
48 }
49
51 public int getNumSamples() {
52 return points.getPointSet().getNumPoints();
53 }
54
60 randomize();
61 for (PointSetIterator it = points.iterator(); it.hasNextPoint(); it.resetToNextPoint()) {
62 model.simulate(it);
63 collector.observe(model.getPerformance());
64 }
65 }
66
71 public void simulateRuns(MonteCarloModelDouble model, Tally collector) {
72 randomize();
73 for (PointSetIterator it = points.iterator(); it.hasNextPoint(); it.resetToNextPoint()) {
74 model.simulate(it);
75 collector.add(model.getPerformance());
76 }
77 }
78
79 @Override
80 public String toString() {
81 return "RQMC Sampler [points=" + points.getPointSet().getNumPoints() + "]" + " [dimension="
82 + points.getPointSet().getDimension() + "]" + " [pointset="
83 + points.getPointSet().getClass().getSimpleName() + "]" + " [randomization="
84 + points.getRandomization().getClass().getSimpleName() + "]";
85 }
86
93 protected void randomize() {
94 points.randomize();
95 if (getStream() instanceof PointSetIterator)
96 ((PointSetIterator) getStream()).resetToNextPoint();
97 }
98}
int getNumPoints()
Returns the number of points.
int getDimension()
Returns the dimension (number of available coordinates) of the points.
This class is used for randomized quasi-Monte Carlo (RQMC) simulations.
PointSet getPointSet()
Returns the point set associated to this object.
PointSetRandomization getRandomization()
Returns the randomization associated to this object.
public< E > void simulateRuns(MonteCarloModel<? extends E > model, ObservationCollector< E > collector)
void setStream(RandomStream stream)
Use stream as the source of randomness.
RandomStream getStream()
Returns the currently used random stream.
void randomize()
Randomizes the integrator by randomizing the internal point set.
RQMCPointSet getRQMCPointSet()
Returns the internal RQMC point set.
int getNumSamples()
Returns the number of samples produced each time the simulateRuns() method is called.
void simulateRuns(MonteCarloModelDouble model, Tally collector)
int getNumSimulationsPerSample()
Returns the number of times the model is simulated each time a sample is produced.
A subclass of StatProbe.
Definition Tally.java:47
void add(double x)
Gives a new observation x to the statistical collector.
Definition Tally.java:109
This is the interface for iterators that permit one to go through the points of a PointSet and the su...
boolean hasNextPoint()
Returns true if there is a next point.
An interface for a very simple simulation model for which Monte Carlo (MC) and RQMC experiments are t...
void simulate(RandomStream stream)
Simulates the model for one run.
double getPerformance()
Recovers and returns the realization of the performance measure, of type double.
An interface for a simple simulation model for which Monte Carlo (MC) or RQMC experiments are to be p...
void simulate(RandomStream stream)
Simulates the model for one run, using the given stream.
E getPerformance()
Recovers and returns the realization of the performance measure, of type E.
This interface defines the basic structures to handle multiple streams of uniform (pseudo)random numb...