Skip to content

Commit

Permalink
Add documentation to the BigRNG
Browse files Browse the repository at this point in the history
  • Loading branch information
andrioni committed Nov 19, 2013
1 parent 5cb8606 commit 4bf4829
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 10 deletions.
59 changes: 53 additions & 6 deletions doc/helpdb.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3885,7 +3885,8 @@ popdisplay(d::Display)

("Mathematical Functions","Base","gcd","gcd(x, y)
Greatest common (positive) divisor (or zero if x and y are both zero).
Greatest common (positive) divisor (or zero if x and y are both
zero).
"),

Expand All @@ -3897,8 +3898,8 @@ popdisplay(d::Display)

("Mathematical Functions","Base","gcdx","gcdx(x, y)
Greatest common (positive) divisor, also returning integer coefficients \"u\"
and \"v\" that solve \"ux+vy == gcd(x,y)\"
Greatest common (positive) divisor, also returning integer
coefficients \"u\" and \"v\" that solve \"ux+vy == gcd(x,y)\"
"),

Expand Down Expand Up @@ -4769,7 +4770,8 @@ popdisplay(d::Display)
Seed the RNG with a \"seed\", which may be an unsigned integer or a
vector of unsigned integers. \"seed\" can even be a filename, in
which case the seed is read from a file. If the argument \"rng\" is
not provided, the default global RNG is seeded.
not provided, the default global RNG and the default BigRNG are
seeded.
"),

Expand All @@ -4781,9 +4783,24 @@ popdisplay(d::Display)
"),

("Random Numbers","Base","BigRNG","BigRNG([seed])
Create a \"BigRNG\" RNG object, used exclusively to generate random
BigInts and BigFloats. Different RNG objects can have their own
seeds, which may be useful for generating different streams of
random numbers.
"),

("Random Numbers","Base","rand","rand()
Generate a \"Float64\" random number uniformly in [0,1)
Generate a \"Float64\" random number uniformly in [0,1).
"),

("Random Numbers","Base","rand","rand(BigFloat)
Generate a \"BigFloat\" random number uniformly in [0,1).
"),

Expand All @@ -4803,9 +4820,24 @@ popdisplay(d::Display)
"),

("Random Numbers","Base","rand","rand(BigFloat, rng::AbstractRNG[, dims...])
Generate a random \"BigFloat\" number or array of the size
specified by dims, using the specified RNG object. Currently,
\"BigRNG\" is the only available Random Number Generator (RNG) for
BigFloats, which may be seeded using srand.
"),

("Random Numbers","Base","rand","rand(dims or [dims...])
Generate a random \"Float64\" array of the size specified by dims
Generate a random \"Float64\" array of the size specified by dims.
"),

("Random Numbers","Base","rand","rand(BigFloat, dims or [dims...])
Generate a random \"BigFloat\" array of the size specified by dims.
"),

Expand Down Expand Up @@ -4846,13 +4878,28 @@ popdisplay(d::Display)
"),

("Random Numbers","Base","randn","randn(BigFloat, dims or [dims...])
Generate a normally-distributed random BigFloat with mean 0 and
standard deviation 1. Optionally generate an array of normally-
distributed random BigFloats.
"),

("Random Numbers","Base","randn!","randn!(A::Array{Float64, N})
Fill the array A with normally-distributed (mean 0, standard
deviation 1) random numbers. Also see the rand function.
"),

("Random Numbers","Base","randn!","randn!(A::Array{BigFloat, N})
Fill the array A with normally-distributed (mean 0, standard
deviation 1) random BigFloats. Also see the rand function.
"),

("Random Numbers","Base","randsym","randsym(n)
Generate a \"nxn\" symmetric array of normally-distributed random
Expand Down
32 changes: 28 additions & 4 deletions doc/stdlib/base.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3206,19 +3206,27 @@ The `BigFloat` type implements arbitrary-precision floating-point aritmetic usin
Random Numbers
--------------

Random number generateion in Julia uses the `Mersenne Twister library <http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/#dSFMT>`_. Julia has a global RNG, which is used by default. Multiple RNGs can be plugged in using the ``AbstractRNG`` object, which can then be used to have multiple streams of random numbers. Currently, only ``MersenneTwister`` is supported.
Random number generation in Julia uses the `Mersenne Twister library <http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/#dSFMT>`_. Julia has a global RNG, which is used by default. Multiple RNGs can be plugged in using the ``AbstractRNG`` object, which can then be used to have multiple streams of random numbers. Currently, only ``MersenneTwister`` is supported. For the generation of BigInts and BigFloats, GMP's own Mersenne Twister implementation is used instead.

.. function:: srand([rng], seed)

Seed the RNG with a ``seed``, which may be an unsigned integer or a vector of unsigned integers. ``seed`` can even be a filename, in which case the seed is read from a file. If the argument ``rng`` is not provided, the default global RNG is seeded.
Seed the RNG with a ``seed``, which may be an unsigned integer or a vector of unsigned integers. ``seed`` can even be a filename, in which case the seed is read from a file. If the argument ``rng`` is not provided, the default global RNG and the default BigRNG are seeded.

.. function:: MersenneTwister([seed])

Create a ``MersenneTwister`` RNG object. Different RNG objects can have their own seeds, which may be useful for generating different streams of random numbers.

.. function:: BigRNG([seed])

Create a ``BigRNG`` RNG object, used exclusively to generate random BigInts and BigFloats. Different RNG objects can have their own seeds, which may be useful for generating different streams of random numbers.

.. function:: rand()

Generate a ``Float64`` random number uniformly in [0,1)
Generate a ``Float64`` random number uniformly in [0,1).

.. function:: rand(BigFloat)

Generate a ``BigFloat`` random number uniformly in [0,1).

.. function:: rand!([rng], A)

Expand All @@ -3228,9 +3236,17 @@ Random number generateion in Julia uses the `Mersenne Twister library <http://ww

Generate a random ``Float64`` number or array of the size specified by dims, using the specified RNG object. Currently, ``MersenneTwister`` is the only available Random Number Generator (RNG), which may be seeded using srand.

.. function:: rand(BigFloat, rng::AbstractRNG, [dims...])

Generate a random ``BigFloat`` number or array of the size specified by dims, using the specified RNG object. Currently, ``BigRNG`` is the only available Random Number Generator (RNG) for BigFloats, which may be seeded using srand.

.. function:: rand(dims or [dims...])

Generate a random ``Float64`` array of the size specified by dims
Generate a random ``Float64`` array of the size specified by dims.

.. function:: rand(BigFloat, dims or [dims...])

Generate a random ``BigFloat`` array of the size specified by dims.

.. function:: rand(Int32|Uint32|Int64|Uint64|Int128|Uint128, [dims...])

Expand All @@ -3252,10 +3268,18 @@ Random number generateion in Julia uses the `Mersenne Twister library <http://ww

Generate a normally-distributed random number with mean 0 and standard deviation 1. Optionally generate an array of normally-distributed random numbers.

.. function:: randn(BigFloat, dims or [dims...])

Generate a normally-distributed random BigFloat with mean 0 and standard deviation 1. Optionally generate an array of normally-distributed random BigFloats.

.. function:: randn!(A::Array{Float64,N})

Fill the array A with normally-distributed (mean 0, standard deviation 1) random numbers. Also see the rand function.

.. function:: randn!(A::Array{BigFloat,N})

Fill the array A with normally-distributed (mean 0, standard deviation 1) random BigFloats. Also see the rand function.

.. function:: randsym(n)

Generate a ``nxn`` symmetric array of normally-distributed random numbers with mean 0 and standard deviation 1.
Expand Down

0 comments on commit 4bf4829

Please sign in to comment.