[NTG-pdftex] Re: Uniform and Normal Distribution Pseudo-random numbers patch

Martin Schröder martin at oneiros.de
Sat Jul 2 20:19:30 CEST 2005

On 2005-06-27 16:53:12 +0200, Taco Hoekwater wrote:
>   randoms.ch --
>   This is a WEB change file for pseudo-random numbers in
>   pdftex 1.30 and above.
>   There are four new primitives:
>   \uniformdeviate <count>
>    Generates a uniformly distributed random integer value
>    between 0 (inclusive) and <count> (exclusive).
>    This primitive expands to a list of tokens.
>   \normaldeviate
>    Expands to a random integer value with a mean of 0 and a
>    unit of 65536.
>    This primitive expands to a list of tokens.
>   \randomseed
>    You can use \the\randomseed to query the current seed value,
>    so you can e.g. the value to the log file.
>    The initial value of the seed is derived from the system time,
>    and is not more than 1,000,999,999 (this ensures that the value
>    can be used with commands like \count).
>   \setrandomseed <count>
>    This sets the random seed to a specific value, allowing you
>    to re-play sequences fo semi-randoms at a later moment.
>   Most of the actual code is taken from metapost, and originally
>   written by Knuth, for Metafont. Glue to make it work in TeX is
>   by me. If you find an error, it is bound to be in my code,
>   not Knuth's :-)

Very nice. I've added a call of init_randoms(random_seed) to
"Implement \.{\\ptexsetrandomseed}"; this allows one to restart
the random generator.

And I've renamed the primitives to \ptexuniformdeviate,
\ptexnormaldeviate, \ptexrandomseed and \ptexsetrandomseed.

Best regards

More information about the ntg-pdftex mailing list