GeneralRandom Number Generator for Worksheets?

LaTeX specific issues not fitting into one of the other forums of this category.
rais
Posts: 419
Joined: Sun Nov 16, 2014 8:51 pm

Random Number Generator for Worksheets?

Post by rais »

LaTexLearner wrote: Doesn't {random(0,10)} already create a random value?
yes, well, pseudo-random.

If you were to use a fixed number for this seed, e.g., \pgfmathsetseed{1}, you'd get a seemingly random result.
On a second run, you would get the same result, because the number generation follows certain rules---AFAICS the term is `linear congruency generator', but I didn't look too closely into that.

With a randomized seed as in Stefan's code, two consecutive LaTeX runs should generate different results (unless the seed was randomly set to the same value for both runs).

OTOH, you might get sufficient results using the default value for this seed, which is \time x \year (i.e., commenting out the \pgfmathsetseed line).

KR
Rainer

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
Post Reply