

PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 
java.lang.Object org.apache.commons.math3.random.CorrelatedRandomVectorGenerator
public class CorrelatedRandomVectorGenerator
A RandomVectorGenerator
that generates vectors with with
correlated components.
Random vectors with correlated components are built by combining the uncorrelated components of another random vector in such a way that the resulting correlations are the ones specified by a positive definite covariance matrix.
The main use for correlated random vector generation is for MonteCarlo
simulation of physical problems with several variables, for example to
generate error vectors to be added to a nominal vector. A particularly
interesting case is when the generated vector should be drawn from a
Multivariate Normal Distribution. The approach using a Cholesky
decomposition is quite usual in this case. However, it can be extended
to other cases as long as the underlying random generator provides
normalized values
like GaussianRandomGenerator
or UniformRandomGenerator
.
Sometimes, the covariance matrix for a given simulation is not
strictly positive definite. This means that the correlations are
not all independent from each other. In this case, however, the non
strictly positive elements found during the Cholesky decomposition
of the covariance matrix should not be negative either, they
should be null. Another nonconventional extension handling this case
is used here. Rather than computing C = U^{T}.U
where C
is the covariance matrix and U
is an uppertriangular matrix, we compute C = B.B^{T}
where B
is a rectangular matrix having
more rows than columns. The number of columns of B
is
the rank of the covariance matrix, and it is the dimension of the
uncorrelated random vector that is needed to compute the component
of the correlated vector. This class handles this situation
automatically.
Constructor Summary  

CorrelatedRandomVectorGenerator(double[] mean,
RealMatrix covariance,
double small,
NormalizedRandomGenerator generator)
Builds a correlated random vector generator from its mean vector and covariance matrix. 

CorrelatedRandomVectorGenerator(RealMatrix covariance,
double small,
NormalizedRandomGenerator generator)
Builds a null mean random correlated vector generator from its covariance matrix. 
Method Summary  

NormalizedRandomGenerator 
getGenerator()
Get the underlying normalized components generator. 
int 
getRank()
Get the rank of the covariance matrix. 
RealMatrix 
getRootMatrix()
Get the root of the covariance matrix. 
double[] 
nextVector()
Generate a correlated random vector. 
Methods inherited from class java.lang.Object 

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait 
Constructor Detail 

public CorrelatedRandomVectorGenerator(double[] mean, RealMatrix covariance, double small, NormalizedRandomGenerator generator)
mean
 Expected mean values for all components.covariance
 Covariance matrix.small
 Diagonal elements threshold under which column are
considered to be dependent on previous ones and are discardedgenerator
 underlying generator for uncorrelated normalized
components.
NonPositiveDefiniteMatrixException
 if the covariance matrix is not strictly positive definite.
DimensionMismatchException
 if the mean and covariance
arrays dimensions do not match.public CorrelatedRandomVectorGenerator(RealMatrix covariance, double small, NormalizedRandomGenerator generator)
covariance
 Covariance matrix.small
 Diagonal elements threshold under which column are
considered to be dependent on previous ones and are discarded.generator
 Underlying generator for uncorrelated normalized
components.
NonPositiveDefiniteMatrixException
 if the covariance matrix is not strictly positive definite.Method Detail 

public NormalizedRandomGenerator getGenerator()
public int getRank()
getRootMatrix()
public RealMatrix getRootMatrix()
B
such that
the covariance matrix is equal to B.B^{T}
getRank()
public double[] nextVector()
nextVector
in interface RandomVectorGenerator


PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 