Tensor.Random Method

Definition

Namespace: Numerics.NET.Tensors
Assembly: Numerics.NET.Tensors (in Numerics.NET.Tensors.dll) Version: 10.3.0

Overload List

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

Random(TensorShape, ArrayMutability)

Constructs a new tensor with uniform random numbers between 0 and 1.
C#
public static Tensor<double> Random(
	TensorShape shape,
	ArrayMutability mutability = ArrayMutability.MutableValues
)

Parameters

shape  TensorShape
The shape of the tensor.
mutability  ArrayMutability  (Optional)
Optional. Specifies how the tensor's values may be changed. The default is mutable values.

Return Value

Tensor<Double>
A Tensor<T>.

Exceptions

ArgumentException

shape is not a valid tensor shape.

Random(TensorShape, IRandomSource, ArrayMutability)

Constructs a new tensor with uniform random numbers between 0 and 1.
C#
public static Tensor<double> Random(
	TensorShape shape,
	IRandomSource random,
	ArrayMutability mutability = ArrayMutability.MutableValues
)

Parameters

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

Return Value

Tensor<Double>
A Tensor<T>.

Exceptions

ArgumentException

shape is not a valid tensor shape.

Random(TensorShape, Random, ArrayMutability)

Constructs a new tensor with uniform random numbers between 0 and 1.
C#
public static Tensor<double> Random(
	TensorShape shape,
	Random random,
	ArrayMutability mutability = ArrayMutability.MutableValues
)

Parameters

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

Return Value

Tensor<Double>
A Tensor<T>.

Exceptions

ArgumentException

shape is not a valid tensor shape.

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

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

Parameters

shape  TensorShape
The shape of the tensor.
random  IRandomSource<TGenerator>
The random number generator to use.
mutability  ArrayMutability  (Optional)
Optional. Specifies how the tensor'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

Tensor<Double>
A Tensor<T>.

Exceptions

ArgumentException

shape is not a valid tensor shape.

See Also