beetlebug▾
/

ztcl::tensor randn

Makes a tensor of normal random numbers from a seed.

ztcl::tensor randn SHAPE ?-seed N? ?-dtype DTYPE? ?-mean M? ?-std S?

Description

Makes a tensor of SHAPE with normal numbers of the mean M (default 0) and the standard deviation S (default 1), from splitmix64 with the seed N (default 0) and the Box-Muller transform.

Returns

A tensor.

Examples

Each example of this page runs after package require ztcl::tensor.

% ztcl::tensor randn 2 -seed 3 -dtype f64
tensor f64 2 {-0.15078931135351334 -0.46701055898018695}

Errors

% ztcl::tensor randn 3 -seed x
expected integer but got "x"
-errorcode TCL VALUE NUMBER

Facts

Capability
None.
Tcl release
Tcl 9.1 and 8.6.
Since
ztcl 1.0.0-beta.4
Compute cost
A cost for each element operation by its kind (a copy, an add, a division, a math function, a multiply-add of a matmul), set so that one compute unit takes about the time of one unit of plain Tcl. docs/modules/tensor.md has the table.