init

Function init 

Source
pub fn init<T>(n: usize, d: usize) -> Vec<Vec<T>>
where T: Float + FromPrimitive,
Expand description

Generates a vector of random initial positions from a standard normal distribution.

Each position is a Vec<T> of length d representing a point in d-dimensional space. The function returns n such positions.

§Type Parameters

  • T: The numeric type (e.g., f32, f64). Must implement Float + FromPrimitive.

§Parameters

  • n: Number of positions to generate.
  • d: Dimensionality of each position.

§Returns

A Vec<Vec<T>> where each inner vector is a position in d-dimensional space.

§Panics

Panics if an observation cannot be converted from f64 to T (should never happen for f32 or f64).

§Examples

let positions: Vec<Vec<f32>> = init(5, 3);
for pos in positions {
    println!("{:?}", pos);
}