Skip to main content

Mojo function

random_normal

random_normal[dtype: DType, rank: Int, //, output_fn: fn[Int, Int](idx: IndexList[$1], val: SIMD[dtype, $0]) capturing -> None, target: StringSlice[StaticConstantOrigin]](shape: IndexList[rank], mean: SIMD[dtype, 1], stddev: SIMD[dtype, 1], seed_value: SIMD[uint64, 1], ctx: DeviceContextPtr)

Call output_fn with values generated from a normal distribution with the specified mean and standard deviation.

Parameters:

  • dtype (DType): The data type to generate.
  • rank (Int): The rank of the underlying buffer.
  • output_fn (fn[Int, Int](idx: IndexList[$1], val: SIMD[dtype, $0]) capturing -> None): The function which stores the generated values.
  • target (StringSlice): The target to run on.

Args:

  • shape (IndexList): The shape of the output being stored into by output_fn.
  • mean (SIMD): The mean of the normal distribution.
  • stddev (SIMD): The standard deviation of the normal distribution.
  • seed_value (SIMD): Seed value used to initialize the random number generator.
  • ctx (DeviceContextPtr): The device context.

Was this page helpful?