Вопрос:

What is the role of warm up in random generator?

random gsl

169 просмотра

1 ответ

28 Репутация автора

In GSL there are many random generators. For example, an implementation of the maximally equidistributed combined Tausworthe generator locates at gsl/taus.c. The random seeds is set in the following function:

static inline unsigned long
taus_get (void *vstate)
{
  taus_state_t *state = (taus_state_t *) vstate;

#define MASK 0xffffffffUL
#define TAUSWORTHE(s,a,b,c,d) (((s &c) <<d) &MASK) ^ ((((s <<a) &MASK)^s) >>b)

  state->s1 = TAUSWORTHE (state->s1, 13, 19, 4294967294UL, 12);
  state->s2 = TAUSWORTHE (state->s2, 2, 25, 4294967288UL, 4);
  state->s3 = TAUSWORTHE (state->s3, 3, 11, 4294967280UL, 17);

  return (state->s1 ^ state->s2 ^ state->s3);
}

static void
taus_set (void *vstate, unsigned long int s)
{
  taus_state_t *state = (taus_state_t *) vstate;

  if (s == 0)
    s = 1;      /* default seed is 1 */

#define LCG(n) ((69069 * n) & 0xffffffffUL)
  state->s1 = LCG (s);
  state->s2 = LCG (state->s1);
  state->s3 = LCG (state->s2);

  /* "warm it up" */
  taus_get (state);
  taus_get (state);
  taus_get (state);
  taus_get (state);
  taus_get (state);
  taus_get (state);
  return;
}

My question is why do they need six "warm up"? Is there something wrong if there is no warm up?

Автор: Jannus YU Источник Размещён: 08.11.2017 11:50

Ответы (1)


1 плюс

375 Репутация автора

Six is likely an arbitrary number. Not to small such that there is insufficient randomness and not so large that it slows down startup.

There is no mention of it in the paper referenced in the code you posted. Another paper (http://www0.cs.ucl.ac.uk/staff/d.jones/GoodPracticeRNG.pdf) does discuss the need for "warming up" random number generators.

Essentially, it is used when "your seed values have very low entropy". The discussion is on page 9 of the referenced paper.

Автор: R Schultz Размещён: 09.11.2017 12:26
Вопросы из категории :
32x32