hmmer-3.3/easel/esl_random.c
/* Function:  esl_randomness_CreateFast()
 * Synopsis:  Create the alternative fast generator.
 *            
 * THIS FUNCTION IS DEPRECATED. USE esl_randomness_Create() INSTEAD.
 *
 * Purpose:   Same as <esl_randomness_Create()>, except that a simple
 *            linear congruential generator (LCG) will be used.
 *            This is a $(a=69069, c=1)$ LCG, with a period of
 *            $2^{32}$. 
 *            
 *            This is a low quality RNG. It fails several standard
 *            NIST statistical tests. Successive samples from an LCG
 *            are correlated, and it has a relatively short period. IT
 *            SHOULD NOT BE USED (period). It is present in Easel for
 *            legacy reasons. It used to be substantially faster than
 *            our high quality RNG, but now our default Mersenne
 *            Twister is plenty fast. We have regression and unit
 *            tests that use the LCG and depend on a fixed seed and a
 *            particular pseudorandom number sequence; they would have
 *            to be re-studied carefully to upgrade them to a
 *            different RNG.
 * 
 *            Here's an example of how serial correlation arises in an
 *            LCG, and how it can lead to serious (and difficult to
 *            diagnose) failure in a Monte Carlo simulation.  An LCG
 *            calculates $x_{i+1} = ax_i + c$. Suppose $x_i$ is small:
 *            in the range 0..6000, say, as a specific example. Now
 *            $x_{i+1}$ cannot be larger than 4.1e8, for an LCG with
 *            $a=69069$,$c=1$. So if you take a sample and test
 *            whether it is $< 1e-6$ (say), the next sample will be in
 *            a range of about 0..0.1, rather than being uniform on
 *            0..1.
 *
 * Args:      seed $>= 0$.
 *
 * Returns:   an initialized <ESL_RANDOMNESS *> on success.
 *            Caller free's with <esl_randomness_Destroy()>.
 *              
 * Throws:    <NULL> on failure.
 *
 * Xref:      SRE:J5/44: for accidental proof that period is indeed 2^32.
 */
esl_randomness_CreateFast()
Synopsis:  Create the alternative fast generator.

THIS FUNCTION IS DEPRECATED.

Same as , except that a simple
linear congruential generator (LCG) will be used.

This is a low quality RNG. It fails several standard
NIST statistical tests. Successive samples from an LCG
are correlated, and it has a relatively short period. IT
SHOULD NOT BE USED (period). It is present in Easel for
legacy reasons. It used to be substantially faster than
our high quality RNG, but now our default Mersenne
Twister is plenty fast. We have regression and unit
tests that use the LCG and depend on a fixed seed and a
particular pseudorandom number sequence; they would have
to be re-studied carefully to upgrade them to a
different RNG.

Here's an example of how serial correlation arises in an
LCG, and how it can lead to serious (and difficult to
diagnose) failure in a Monte Carlo simulation.  An LCG
calculates $x_{i+1} = ax_i + c$. Suppose $x_i$ is small:
in the range 0..6000, say, as a specific example.



an initialized  on success.
Caller free's with .

 on failure.

J5/44: for accidental proof that period is indeed 2^32.
esl_randomness_CreateFast () Synopsis : Create the alternative fast generator . THIS FUNCTION IS DEPRECATED . Same as except that a simple linear congruential generator ( LCG ) will be used . This is a low quality RNG . It fails several standard NIST statistical tests . Successive samples from an LCG are correlated and it has a relatively short period . IT SHOULD NOT BE USED ( period ) . It is present in Easel for legacy reasons . It used to be substantially faster than our high quality RNG but now our default Mersenne Twister is plenty fast . We have regression and unit tests that use the LCG and depend on a fixed seed and a particular pseudorandom number sequence ; they would have to be re - studied carefully to upgrade them to a different RNG . Here ' s an example of how serial correlation arises in an LCG and how it can lead to serious ( and difficult to diagnose ) failure in a Monte Carlo simulation . An LCG calculates $x_ { i + 1 } = ax_i + c$ . Suppose $x_i$ is small : in the range 0 .. 6000 say as a specific example . an initialized on success . Caller free ' s with . on failure . J5 / 44 : for accidental proof that period is indeed 2^32 .
ESL_RANDOMNESS *
esl_randomness_CreateFast(uint32_t seed)
{
  ESL_RANDOMNESS *r      = NULL;
  int             status;
  ESL_ALLOC(r, sizeof(ESL_RANDOMNESS));
  r->type = eslRND_FAST;
  r->mti  = 0;
  r->x    = 0;
  r->seed = 0;
  esl_randomness_Init(r, seed);
  return r;
 ERROR:
  return NULL;
}
ESL_RANDOMNESS * esl_randomness_CreateFast ( uint32_t seed ) { ESL_RANDOMNESS * r = NULL ; int status ; ESL_ALLOC ( r , sizeof ( ESL_RANDOMNESS ) ) ; r -> type = eslRND_FAST ; r -> mti = 0 ; r -> x = 0 ; r -> seed = 0 ; esl_randomness_Init ( r , seed ) ; return r ; ERROR : return NULL ; }
Function:  esl_randomness_CreateFast()
 Synopsis:  Create the alternative fast generator.
Function : esl_randomness_CreateFast () Synopsis : Create the alternative fast generator .