normal_gaussian
normal_gaussian(
mean: T,
std: T,
shape: &[i64] | &Vec<i64> | &[i64; _]
) -> Result<Tensor<T>, TensorError>
Create a Tensor with values drawn from a normal (Gaussian) distribution with specified mean and standard deviation. The normal distribution is a continuous probability distribution that is symmetric around its mean, showing the familiar bell-shaped curve.
Parameters:
mean
: Mean (μ) of the distribution, determining the center of the bell curve.
std
: Standard deviation (σ) of the distribution, determining the spread. Must be positive.
shape
: Shape of the output tensor.
Returns:
Tensor with type T
containing random values from the normal distribution.
Examples:
use hpt::{error::TensorError, ops::Random, Tensor};
fn main() -> Result<(), TensorError> {
// Create a 10x10 tensor with normal distribution (μ=0.0, σ=1.0)
let a = Tensor::<f32>::normal_gaussian(0.0, 1.0, &[10, 10])?;
println!("{}", a);
Ok(())
}
Backend Support
Backend | Supported |
---|---|
CPU | ✅ |
Cuda | ❌ |