Vector.Random Method

Definition

Namespace: Numerics.NET
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.8.0

Overload List

Random(Int32, ArrayMutability) Constructs a new vector with uniform random numbers between 0 and 1.
Random(Int32, IRandomSource, ArrayMutability) Constructs a new vector with uniform random numbers between 0 and 1.
Random(Int32, Random, ArrayMutability) Constructs a new vector with uniform random numbers between 0 and 1.
Random<TGenerator>(Int32, IRandomSource<TGenerator>, ArrayMutability) Constructs a new vector with uniform random numbers between 0 and 1.

Random(Int32, ArrayMutability)

Constructs a new vector with uniform random numbers between 0 and 1.
C#
public static DenseVector<double> Random(
	int length,
	ArrayMutability mutability = ArrayMutability.MutableValues
)

Parameters

length  Int32
The length of the vector.
mutability  ArrayMutability  (Optional)
Specifies how the vector's values may be changed. The default is mutable values.

Return Value

DenseVector<Double>
A DenseVector<T>.

Exceptions

ArgumentOutOfRangeExceptionlength is less than zero.

Random(Int32, IRandomSource, ArrayMutability)

Constructs a new vector with uniform random numbers between 0 and 1.
C#
public static DenseVector<double> Random(
	int length,
	IRandomSource random,
	ArrayMutability mutability = ArrayMutability.MutableValues
)

Parameters

length  Int32
The length of the vector.
random  IRandomSource
The random number generator to use.
mutability  ArrayMutability  (Optional)
Specifies how the vector's values may be changed. The default is mutable values.

Return Value

DenseVector<Double>
A DenseVector<T>.

Exceptions

ArgumentOutOfRangeExceptionlength is less than zero.
ArgumentNullExceptionrandom is null.

Random(Int32, Random, ArrayMutability)

Constructs a new vector with uniform random numbers between 0 and 1.
C#
public static DenseVector<double> Random(
	int length,
	Random random,
	ArrayMutability mutability = ArrayMutability.MutableValues
)

Parameters

length  Int32
The length of the vector.
random  Random
The random number generator to use.
mutability  ArrayMutability  (Optional)
Specifies how the vector's values may be changed. The default is mutable values.

Return Value

DenseVector<Double>
A DenseVector<T>.

Exceptions

ArgumentOutOfRangeExceptionlength is less than zero.
ArgumentNullExceptionrandom is null.

Random<TGenerator>(Int32, IRandomSource<TGenerator>, ArrayMutability)

Constructs a new vector with uniform random numbers between 0 and 1.
C#
public static DenseVector<double> Random<TGenerator>(
	int length,
	IRandomSource<TGenerator> random,
	ArrayMutability mutability = ArrayMutability.MutableValues
)
where TGenerator : struct, new(), IRandomGenerator

Parameters

length  Int32
The length of the vector.
random  IRandomSource<TGenerator>
The random number generator to use.
mutability  ArrayMutability  (Optional)
Specifies how the vector's values may be changed. The default is mutable values.

Type Parameters

TGenerator
The underlying generator type of the random source, used to enable optimizations like inlining.

Return Value

DenseVector<Double>
A DenseVector<T>.

Exceptions

ArgumentOutOfRangeExceptionlength is less than zero.
ArgumentNullExceptionrandom is null.

See Also