randexp
randexp([rng], [dims...])
Generate a random number according to the exponential distribution with scale 1. Optionally generate an array of such random numbers.
Examples
-
Generate a single random number:
julia> randexp() 0.21863463412937835This example generates a single random number from the exponential distribution with scale 1.
-
Generate an array of random numbers:
julia> randexp(3) 3-element Array{Float64,1}: 0.6534270514351252 0.2677917751405643 1.211819209742624It generates an array of 3 random numbers from the exponential distribution.
- Generate random numbers using a specific random number generator:
julia> rng = MersenneTwister(1234); # Create a specific RNG julia> randexp(rng) 1.8387810033340432This example uses a specific random number generator
rngto generate a random number from the exponential distribution.
Common mistake example:
julia> randexp(-1)
ERROR: DomainError: The scale parameter of the exponential distribution must be positive
In this example, a negative value is provided as the scale parameter, which results in a domain error. It's important to provide a positive value for the scale parameter to ensure correct behavior of randexp.
See Also
bitrand, MersenneTwister, rand, randcycle, randexp, randexp!, randjump, randn, randn!, RandomDevice, randperm, randsubseq, randsubseq!, shuffle, srand,User Contributed Notes
Add a Note
The format of note supported is markdown, use triple backtick to start and end a code block.