Class CommonRandomNumbers
- java.lang.Object
-
- dev.nm.stat.random.variancereduction.CommonRandomNumbers
-
- All Implemented Interfaces:
MeanEstimator
public class CommonRandomNumbers extends Object implements MeanEstimator
The common random numbers is a variance reduction technique to apply when we are comparing two random systems, e.g., \(E(f(X_1) - g(X_2))\). CRN requires synchronization of the random number streams, which ensures that the same random numbers are used to simulate all systems.
-
-
Constructor Summary
Constructors Constructor Description CommonRandomNumbers(UnivariateRealFunction f, UnivariateRealFunction g)
Estimate \(E(f(X_1) - g(X_2))\), where f and g are functions of uniform random variables.CommonRandomNumbers(UnivariateRealFunction f, UnivariateRealFunction g, RandomLongGenerator X1)
Estimates \(E(f(X_1) - g(X_2))\), where f and g are functions of uniform random variables.CommonRandomNumbers(UnivariateRealFunction f, UnivariateRealFunction g, RandomLongGenerator X1, UnivariateRealFunction X2)
Estimates \(E(f(X_1) - g(X_2))\), where f and g are functions of uniform random variables.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
cov()
Gets the covariance between f and g.Estimator
estimate(int n)
Gets an estimator.
-
-
-
Constructor Detail
-
CommonRandomNumbers
public CommonRandomNumbers(UnivariateRealFunction f, UnivariateRealFunction g, RandomLongGenerator X1, UnivariateRealFunction X2)
Estimates \(E(f(X_1) - g(X_2))\), where f and g are functions of uniform random variables.- Parameters:
f
- the first systemg
- the second systemX1
- a uniform random number generatorX2
- a common number generator; this scheme works only if \(Cov(f(X_1),g(X_2)) > 0\)
-
CommonRandomNumbers
public CommonRandomNumbers(UnivariateRealFunction f, UnivariateRealFunction g, RandomLongGenerator X1)
Estimates \(E(f(X_1) - g(X_2))\), where f and g are functions of uniform random variables. We set X2 = X1.- Parameters:
f
- the first systemg
- the second systemX1
- a uniform random number generator
-
CommonRandomNumbers
public CommonRandomNumbers(UnivariateRealFunction f, UnivariateRealFunction g)
Estimate \(E(f(X_1) - g(X_2))\), where f and g are functions of uniform random variables. We set X2 = X1.- Parameters:
f
- the first systemg
- the second system
-
-
Method Detail
-
cov
public double cov()
Gets the covariance between f and g. The more negative it is, the small the variance.- Returns:
- the covariance between f and g
-
estimate
public Estimator estimate(int n)
Description copied from interface:MeanEstimator
Gets an estimator.- Specified by:
estimate
in interfaceMeanEstimator
- Parameters:
n
- the number of samples to draw for the estimation- Returns:
- an estimator
-
-