RandomSamplingExtensions.CorrelatedSamples Method

Definition

Namespace: Numerics.NET.Statistics.Distributions
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.9.0

Overload List

CorrelatedSamples(IRandomSource, Int32, Distribution[], SymmetricMatrix<Double>) Generates a series of random variables with the specified correlation matrix.
CorrelatedSamples(Random, Int32, Distribution[], SymmetricMatrix<Double>) Generates a series of random variables with the specified correlation matrix.
CorrelatedSamples<TGenerator>(IRandomSource<TGenerator>, Int32, Distribution[], SymmetricMatrix<Double>) Generates a series of random variables with the specified correlation matrix.

CorrelatedSamples(IRandomSource, Int32, Distribution[], SymmetricMatrix<Double>)

Generates a series of random variables with the specified correlation matrix.
C#
public static Vector<double>[] CorrelatedSamples(
	this IRandomSource random,
	int numberOfSamples,
	Distribution[] distributions,
	SymmetricMatrix<double> correlations
)

Parameters

random  IRandomSource
 
numberOfSamples  Int32
The number of samples to generate. Must be at least two and greater than the number of distributions.
distributions  Distribution[]
An array of Distribution objects specifying the probability distribution of each variable.
correlations  SymmetricMatrix<Double>
A SymmetricMatrix specifying the desired correlation matrix.

Return Value

Vector<Double>[]
An array of real vectors with approximately the specified correlation matrix.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IRandomSource. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Remarks

Uses Iman-Conover rank rearrangement, preserving every sampled marginal value. The correlation matrix must be finite and positive definite with a unit diagonal. The sample count must exceed the number of distributions. Singular normal-score permutations are retried a bounded number of times.

Exceptions

ArgumentNullExceptionThe receiver, distributions, or correlations are null.
ArgumentOutOfRangeExceptionThe sample count is less than two.
InsufficientDataExceptionThe sample count does not exceed the number of distributions.
DimensionMismatchExceptionThe matrix dimension differs from the distribution count.
ArgumentExceptionThe marginal list is empty, contains null, or the matrix is invalid.
NotSupportedExceptionA marginal is not a univariate continuous or discrete distribution.
InvalidOperationExceptionIndependent normal-score permutations could not be generated.

CorrelatedSamples<TGenerator>(IRandomSource<TGenerator>, Int32, Distribution[], SymmetricMatrix<Double>)

Generates a series of random variables with the specified correlation matrix.
C#
public static Vector<double>[] CorrelatedSamples<TGenerator>(
	this IRandomSource<TGenerator> random,
	int numberOfSamples,
	Distribution[] distributions,
	SymmetricMatrix<double> correlations
)
where TGenerator : struct, new(), IRandomGenerator

Parameters

random  IRandomSource<TGenerator>
 
numberOfSamples  Int32
The number of samples to generate. Must be at least two and greater than the number of distributions.
distributions  Distribution[]
An array of Distribution objects specifying the probability distribution of each variable.
correlations  SymmetricMatrix<Double>
A SymmetricMatrix specifying the desired correlation matrix.

Type Parameters

TGenerator

Return Value

Vector<Double>[]
An array of real vectors with approximately the specified correlation matrix.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IRandomSource<TGenerator>. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Remarks

Uses Iman-Conover rank rearrangement, preserving every sampled marginal value. The correlation matrix must be finite and positive definite with a unit diagonal. The sample count must exceed the number of distributions. Singular normal-score permutations are retried a bounded number of times.

Exceptions

ArgumentNullExceptionThe receiver, distributions, or correlations are null.
ArgumentOutOfRangeExceptionThe sample count is less than two.
InsufficientDataExceptionThe sample count does not exceed the number of distributions.
DimensionMismatchExceptionThe matrix dimension differs from the distribution count.
ArgumentExceptionThe marginal list is empty, contains null, or the matrix is invalid.
NotSupportedExceptionA marginal is not a univariate continuous or discrete distribution.
InvalidOperationExceptionIndependent normal-score permutations could not be generated.

CorrelatedSamples(Random, Int32, Distribution[], SymmetricMatrix<Double>)

Generates a series of random variables with the specified correlation matrix.
C#
public static Vector<double>[] CorrelatedSamples(
	this Random random,
	int numberOfSamples,
	Distribution[] distributions,
	SymmetricMatrix<double> correlations
)

Parameters

random  Random
 
numberOfSamples  Int32
The number of samples to generate. Must be at least two and greater than the number of distributions.
distributions  Distribution[]
An array of Distribution objects specifying the probability distribution of each variable.
correlations  SymmetricMatrix<Double>
A SymmetricMatrix specifying the desired correlation matrix.

Return Value

Vector<Double>[]
An array of real vectors with approximately the specified correlation matrix.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Random. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Remarks

Uses Iman-Conover rank rearrangement, preserving every sampled marginal value. The correlation matrix must be finite and positive definite with a unit diagonal. The sample count must exceed the number of distributions. Singular normal-score permutations are retried a bounded number of times.

Exceptions

ArgumentNullExceptionThe receiver, distributions, or correlations are null.
ArgumentOutOfRangeExceptionThe sample count is less than two.
InsufficientDataExceptionThe sample count does not exceed the number of distributions.
DimensionMismatchExceptionThe matrix dimension differs from the distribution count.
ArgumentExceptionThe marginal list is empty, contains null, or the matrix is invalid.
NotSupportedExceptionA marginal is not a univariate continuous or discrete distribution.
InvalidOperationExceptionIndependent normal-score permutations could not be generated.

See Also