From 4bf4829eb3a7397edc73348ae1287359605c5c2b Mon Sep 17 00:00:00 2001 From: Alessandro Andrioni Date: Tue, 19 Nov 2013 14:21:47 -0200 Subject: [PATCH] Add documentation to the BigRNG --- doc/helpdb.jl | 59 ++++++++++++++++++++++++++++++++++++++++----- doc/stdlib/base.rst | 32 +++++++++++++++++++++--- 2 files changed, 81 insertions(+), 10 deletions(-) diff --git a/doc/helpdb.jl b/doc/helpdb.jl index 4fbe882a20a17..f6d569f04c40c 100644 --- a/doc/helpdb.jl +++ b/doc/helpdb.jl @@ -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). "), @@ -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)\" "), @@ -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. "), @@ -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). "), @@ -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. "), @@ -4846,6 +4878,14 @@ 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 @@ -4853,6 +4893,13 @@ popdisplay(d::Display) "), +("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 diff --git a/doc/stdlib/base.rst b/doc/stdlib/base.rst index 6dd17e9937580..5079b265a7251 100644 --- a/doc/stdlib/base.rst +++ b/doc/stdlib/base.rst @@ -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 `_. 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 `_. 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) @@ -3228,9 +3236,17 @@ Random number generateion in Julia uses the `Mersenne Twister library