src/random

Search:
Group by:

Creates a new ndarray with random values from uniform distribution.

Values are uniformly distributed in the range [low, high).

Parameters:

  • dims - Array of dimension sizes (must have at least 2 elements)
  • low - Lower bound (inclusive)
  • high - Upper bound (exclusive)

Returns: New NDArray with random uniform values

Raises: ValueError if creation fails

Example:

let arr = newRandomUniform(@[3, 4], 0.0, 1.0)  # Random values in [0, 1)

Creates a new ndarray with random values from normal distribution.

Values follow a Gaussian distribution with specified mean and standard deviation.

Parameters:

  • dims - Array of dimension sizes (must have at least 2 elements)
  • mean - Mean of the distribution
  • stddev - Standard deviation of the distribution

Returns: New NDArray with random normal values

Raises: ValueError if creation fails

Example:

let arr = newRandomNormal(@[3, 4], 0.0, 1.0)  # Standard normal distribution

Procs

proc newRandomNormal(dims: openArray[int]; mean: float; stddev: float): NDArray {.
    ...raises: [ValueError], tags: [], forbids: [].}
proc newRandomUniform(dims: openArray[int]; low: float; high: float): NDArray {.
    ...raises: [ValueError], tags: [], forbids: [].}