Click or drag to resize

NMathFunctionsCorrelatedRandomInputs(Int32, Double, RandomNumberGenerator, RandomNumberGenerator) Method

Creates two sequences of correlated random numbers using the specified random number generators. The created sequence's Spearman rank correlation will be approximately equal to the specified number.

Namespace: CenterSpace.NMath.Core
Assembly: NMath (in NMath.dll) Version: 7.4
Syntax
public static DoubleMatrix CorrelatedRandomInputs(
	int numSamples,
	double desiredCorrelation,
	RandomNumberGenerator xInputs,
	RandomNumberGenerator yInputs
)

Parameters

numSamples  Int32
The number of correlated random numbers to createn
desiredCorrelation  Double
The desired Spearman rank correlation for the the two sequnces. Must be between -1 and 1, inclusive.
xInputs  RandomNumberGenerator
Random number generator for one of the sequences.
yInputs  RandomNumberGenerator
Random number generator for the other sequence.

Return Value

DoubleMatrix
Matrix whose columns are the two sequences of correlated random numbers.
Exceptions
ExceptionCondition
InvalidArgumentExceptionThrown if desired rank correlation is not between -1 and 1.
See Also