Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simpler example for randn #52252

Merged
merged 11 commits into from
Nov 25, 2023
27 changes: 26 additions & 1 deletion stdlib/Random/src/normal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,33 @@ from the circularly symmetric complex normal distribution of variance 1 (corresp
See also [`randn!`](@ref) to act in-place.

# Examples

Generating a single random number, by default of type `Float64`:

```julia-repl
julia> using Random
stevengj marked this conversation as resolved.
Show resolved Hide resolved

julia> randn()
-0.942481877315864
```

Generating a matrix of normal random numbers, by default of type `Float64`:

```julia-repl
julia> using Random

julia> randn(2,3)
2×3 Matrix{Float64}:
1.18786 -0.678616 1.49463
-0.342792 -0.134299 -1.45005
```

Setting up of the random number generator with a user-defined seed, and the generation of a random `ComplexF64` number, or a matrix `ComplexF32` normal random numbers:

```jldoctest
julia> using Random; rng = Xoshiro(123);
julia> using Random

julia> rng = Xoshiro(123);

julia> randn(rng, ComplexF64)
-0.45660053706486897 - 1.0346749725929225im
Expand Down