gpucoder.randn
R2026bSyntax
Description
The gpucoder.randn function generates random numbers from the
standard normal distribution. When you generate GPU code from
gpucoder.randn, the generated code uses the NVIDIA® cuRAND library to generate random numbers on the GPU. When you call
gpucoder.randn in MATLAB®, the function generates random numbers by using the randn function.
Note
Because the cuRAND library and MATLAB use different random number generators, the results of
gpucoder.randn
in MATLAB do not match the results from the generated GPU code.
returns a random scalar
drawn from the normal distribution with a mean of 0 and standard deviation of 1.X = gpucoder.randn
returns an X = gpucoder.randn(sz1,...,szN)sz1-by-...-by-szN array of random numbers
where sz1,...,szN indicates the size of each dimension.
Examples
Input Arguments
Output Arguments
Limitations
Generating complex numbers is not supported.
For code generation, if you use the
szinput argument, the vector must have a fixed size. If you use thesz1,...,szNinput arguments, the number of arguments must be constant. You can change the values inszorsz1,...,szNat run time.
Tips
In generated GPU code, a pseudorandom number generator determines the sequence of numbers generated by
gpucoder.rand,gpucoder.randi, andgpucoder.randn. To control the sequence of random numbers, use thegpucoder.rngfunction.
Extended Capabilities
Version History
Introduced in R2026b