SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.stats.random.variancereduction

Class CommonRandomNumbers

• java.lang.Object
• com.numericalmethod.suanshu.stats.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.
Wolfram Demonstrations Project: The Method of Common Random Numbers: An Example
• Constructor Summary

Constructors
Constructor and 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
Modifier and Type Method and Description
double cov()
Gets the covariance between f and g.
Estimator estimate(int n)
Gets an estimator.
• Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
• 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 system
g - the second system
X1 - a uniform random number generator
X2 - 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 system
g - the second system
X1 - 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 system
g - 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 interface MeanEstimator
Parameters:
n - the number of samples to draw for the estimation
Returns:
an estimator