pub trait RandomConstructors<T: RawDataType>: Constructors<T> {
// Provided methods
fn randn(shape: impl ToVec<usize>) -> Self
where T: FloatDataType { ... }
fn rand(shape: impl ToVec<usize>) -> Self
where T: FloatDataType { ... }
fn uniform(shape: impl ToVec<usize>, low: T, high: T) -> Self
where T: FloatDataType { ... }
fn randint(shape: impl ToVec<usize>, low: T, high: T) -> Self
where T: NumericDataType { ... }
}Provided Methods§
Sourcefn randn(shape: impl ToVec<usize>) -> Selfwhere
T: FloatDataType,
fn randn(shape: impl ToVec<usize>) -> Selfwhere
T: FloatDataType,
Samples an NdArray with the specified shape
from a standard normal distribution (0 mean, unit standard deviation).
§Examples
let ndarray = NdArray::<f64>::randn([2, 3]);
println!("{:?}", ndarray);Sourcefn rand(shape: impl ToVec<usize>) -> Selfwhere
T: FloatDataType,
fn rand(shape: impl ToVec<usize>) -> Selfwhere
T: FloatDataType,
Samples an NdArray with the specified shape
with values uniformly distributed in [0, 1).
§Examples
let ndarray = NdArray::<f64>::rand([2, 3]);
println!("{:?}", ndarray);Sourcefn uniform(shape: impl ToVec<usize>, low: T, high: T) -> Selfwhere
T: FloatDataType,
fn uniform(shape: impl ToVec<usize>, low: T, high: T) -> Selfwhere
T: FloatDataType,
Samples an NdArray with the specified shape
with values uniformly distributed in [low, high).
§Examples
let ndarray = NdArray::<f64>::uniform([2, 3], -5.0, 3.0);
println!("{:?}", ndarray);Sourcefn randint(shape: impl ToVec<usize>, low: T, high: T) -> Selfwhere
T: NumericDataType,
fn randint(shape: impl ToVec<usize>, low: T, high: T) -> Selfwhere
T: NumericDataType,
Samples an NdArray with the specified shape
with integer values uniformly distributed between low (inclusive) and high (exclusive).
§Examples
let ndarray = NdArray::<isize>::randint([2, 3], -5, 3);
println!("{:?}", ndarray);Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.