# Class Rng
Random Number Generator

All Subcl's | MersenneTwisterRng, RngFunctor
Defined in | <seqan/random.h>
Signature | `template <[typename TSpec]> class Rng;`

## Template Parameters

`TSpec` | Tag for selecting the specialization. Defaults to MersenneTwisterRng.

## Member Function Overview

- `TValue Rng::operator();`
  Function all operator.

## Interface Function Overview

- `TValue pickRandomNumber(rng[, pdf]);`
  Pick a random number using a random number generator, possibly using a probability density function.

## Interface Metafunction Overview

- `MaxValue<TRng>::VALUE;`
  Largest value that a Rng can return.
- `MinValue<TRng>::VALUE;`
  Smallest value that a Rng can return.
- `Value<TRng>::Type`
  Value type of a Rng.

## Detailed Description

### Examples

The following code shows how to generate random numbers and shuffle a text.

    #include <iostream>

    #include <seqan/basic.h>
    #include <seqan/stream.h>
    #include <seqan/random.h>

    using namespace seqan;

    const int SEED = 42;

    int main()
    {
        Rng<MersenneTwister> rng(SEED);
        std::cout << "pickRandomNumber(rng) == " << pickRandomNumber(rng) << std::endl;

        Pdf<Uniform<double> > uniformDouble(0, 1);
        std::cout << "pickRandomNumber(rng, uniformDouble) == " << pickRandomNumber(rng, uniformDouble) << std::endl;

        Pdf<Uniform<int> > uniformInt(0, 42);
        std::cout << "pickRandomNumber(rng, uniformInt) == " << pickRandomNumber(rng, uniformInt) << std::endl;

        Pdf<Normal> normal(0, 1);
        std::cout << "pickRandomNumber(rng, normal) == " << pickRandomNumber(rng, normal) << std::endl;

        Pdf<LogNormal> logNormal(0, 1);
        std::cout << "pickRandomNumber(rng, logNormal) == " << pickRandomNumber(rng, logNormal) << std::endl;

        Pdf<LogNormal> logNormal2(0, 1, MuSigma());
        std::cout << "pickRandomNumber(rng, logNormal2) == " << pickRandomNumber(rng, logNormal2) << std::endl;

        Pdf<LogNormal> logNormal3(0.1, 1, MeanStdDev());
        std::cout << "pickRandomNumber(rng, logNormal3) == " << pickRandomNumber(rng, logNormal3) << std::endl;

        CharString container = "Hello World!";
        shuffle(container, rng);
        std::cout << "shuffle(\"Hello World!\") == " << container << std::endl;

        return 0;
    }

Demo: demos/dox/random/random.cpp

    pickRandomNumber(rng) == 1608637542
    pickRandomNumber(rng, uniformDouble) == 0.950714
    pickRandomNumber(rng, uniformInt) == 27
    pickRandomNumber(rng, normal) == 0.419823
    pickRandomNumber(rng, logNormal) == 1.22431
    pickRandomNumber(rng, logNormal2) == 2.78004
    pickRandomNumber(rng, logNormal3) == 0.00155248
    shuffle("Hello World!") ==  o!reWlloHld

## See Also

- http://seqan.readthedocs.org/en/develop/Tutorial/Randomness.html

## Member Functions Detail

### `TValue Rng::operator();`

Function all operator.

#### Returns

`TValue` | Random number, TValue can be retrieved with Rng#Value.

#### Data Races

Thread safety unknown!

## Interface Functions Detail

### `TValue pickRandomNumber(rng[, pdf]);`

Pick a random number using a random number generator, possibly using a probability density function.

#### Parameters

`rng` | The Rng to use.
`pdf` | The probability density function to use.

#### Returns

`TValue` | A random number. TValue is the value type of the rng if pdf is not given. If pdf is given then it is of the value type of pdf.

#### Remarks

For more details see the SeqAn Tutorial on Randomness.

#### Data Races

Thread safety unknown!

## Interface Metafunctions Detail

### `MaxValue<TRng>::VALUE;`

Largest value that a Rng can return.

#### Template Parameters

`TRng` | The Rng object to get the largest value for.

#### Returns

`VALUE` | The largest value a Rng can return.

### `MinValue<TRng>::VALUE;`

Smallest value that a Rng can return.

#### Template Parameters

`TRng` | The Rng object to get the smallest value for.

#### Returns

`VALUE` | The smallest value a Rng can return.

### `Value<TRng>::Type`

Value type of a Rng.

#### Template Parameters

`TRng` | the Rng to get the value type for.

#### Returns

`Type` | the value type for the Rng.

#### Dox Sources

    /*!
     * @class Rng
     *
     * @headerfile <seqan/random.h>
     *
     * @brief Random Number Generator
     *
     * @signature template <[typename TSpec]> class Rng;
     *
     * @tparam TSpec Tag for selecting the specialization. Defaults to @link
     *               MersenneTwisterRng @endlink.
     *
     * @section Examples
     *
     * The following code shows how to generate random numbers and shuffle a text.
     *
     * @include demos/dox/random/random.cpp
     *
     * @code{.console}
     * pickRandomNumber(rng) == 1608637542
     * pickRandomNumber(rng, uniformDouble) == 0.950714
     * pickRandomNumber(rng, uniformInt) == 27
     * pickRandomNumber(rng, normal) == 0.419823
     * pickRandomNumber(rng, logNormal) == 1.22431
     * pickRandomNumber(rng, logNormal2) == 2.78004
     * pickRandomNumber(rng, logNormal3) == 0.00155248
     * shuffle("Hello World!") ==  o!reWlloHld
     * @endcode
     *
     *
     * @see http://seqan.readthedocs.org/en/develop/Tutorial/Randomness.html
     *
     * @mfn Rng#Value
     *
     * @brief Value type of a Rng.
     *
     * @signature Value<TRng>::Type
     *
     * @tparam TRng the Rng to get the value type for.
     *
     * @return Type the value type for the Rng.
     *
     * @mfn Rng#MinValue
     *
     * @brief Smallest value that a Rng can return.
     *
     * @signature MinValue<TRng>::VALUE;
     *
     * @tparam TRng The Rng object to get the smallest value for.
     *
     * @return VALUE The smallest value a Rng can return.
     *
     * @mfn Rng#MaxValue
     *
     * @brief Largest value that a Rng can return.
     *
     * @signature MaxValue<TRng>::VALUE;
     *
     * @tparam TRng The Rng object to get the largest value for.
     *
     * @return VALUE The largest value a Rng can return.
     *
     * @fn Rng::operator()
     *
     * @brief Function all operator.
     *
     * @signature TValue Rng::operator();
     *
     * @return TValue Random number, TValue can be retrieved with Rng#Value.
     *
     * @fn Rng#pickRandomNumber
     *
     * @brief Pick a random number using a random number generator, possibly using a
     *        probability density function.
     *
     * @signature TValue pickRandomNumber(rng[, pdf]);
     *
     * @param[in,out] rng The Rng to use.
     * @param[in] pdf The probability density function to use.
     *
     * @return TValue A random number. TValue is the value type of the rng if pdf is
     *                not given. If pdf is given then it is of the value type of
     *                pdf.
     *
     * @section Remarks
     *
     * For more details see the <a
     * href="http://seqan.readthedocs.org/en/develop/Tutorial/Randomness.html">SeqAn
     * Tutorial on Randomness</a>.
     */