Documentation of 'org.spaceroots.mantissa.random.CorrelatedRandomVectorGenerator' Java class
CorrelatedRandomVectorGenerator
org.spaceroots.mantissa.random

Class CorrelatedRandomVectorGenerator

  • All Implemented Interfaces:
    java.io.Serializable, RandomVectorGenerator


    public class CorrelatedRandomVectorGenerator
    extends java.lang.Object
    implements java.io.Serializable, RandomVectorGenerator
    This class allows to generate random vectors with correlated components.

    Random vectors with correlated components are built by combining the uncorrelated components of another random vector in such a way the resulting correlations are the ones specified by a positive definite covariance matrix.

    Sometimes, the covariance matrix for a given simulation is not strictly positive definite. This means that the correlations are not all independant 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. This implies that rather than computing C = L.Lt where C is the covariance matrix and L is a lower-triangular matrix, we compute C = B.Bt 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 does handle this situation automatically.

    See Also:
    Serialized Form
    • Constructor Detail

      • CorrelatedRandomVectorGenerator

        public CorrelatedRandomVectorGenerator(double[] mean,
                                               SymetricalMatrix covariance,
                                               NormalizedRandomGenerator generator)
                                        throws NotPositiveDefiniteMatrixException
        Simple constructor.

        Build a correlated random vector generator from its mean vector and covariance matrix.

        Parameters:
        mean - expected mean values for all components
        covariance - covariance matrix
        generator - underlying generator for uncorrelated normalized components
        Throws:
        java.lang.IllegalArgumentException - if there is a dimension mismatch between the mean vector and the covariance matrix
        NotPositiveDefiniteMatrixException - if the covariance matrix is not strictly positive definite
    • Method Detail

      • getRootMatrix

        public Matrix getRootMatrix()
        Get the root of the covariance matrix. The root is the matrix B such that B.Bt is equal to the covariance matrix
        Returns:
        root of the square matrix
      • getGenerator

        public NormalizedRandomGenerator getGenerator()
        Get the underlying normalized components generator.
        Returns:
        underlying uncorrelated components generator
      • getRank

        public int getRank()
        Get the rank of the covariance matrix. The rank is the number of independant rows in the covariance matrix, it is also the number of columns of the rectangular matrix of the factorization.
        Returns:
        rank of the square matrix.
      • nextVector

        public double[] nextVector()
        Generate a correlated random vector.
        Specified by:
        nextVector in interface RandomVectorGenerator
        Returns:
        a random vector as an array of double. The returned array is created at each call, the caller can do what it wants with it.

DataMelt 3.0 © DataMelt by jWork.ORG

Ads help maintain this website.