[ pdftex-Patches-376 ] Uniform and Normal Distribution Pseudo-random numbers patch
Patches item #376, was opened at 2005-06-27 16:45 You can respond by visiting: http://sarovar.org/tracker/?func=detail&atid=495&aid=376&group_id=106 Category: Primitives Group: v1.30.0 Status: Open Resolution: None Priority: 5 Submitted By: Taco Hoekwater (taco) Assigned to: Nobody (None) Summary: Uniform and Normal Distribution Pseudo-random numbers patch Initial Comment: See the patch file itself or the mailing list for actual usage and comments. Requested by Pawel. It is intented to be applied after tex.pch (as usual) ---------------------------------------------------------------------- You can respond by visiting: http://sarovar.org/tracker/?func=detail&atid=495&aid=376&group_id=106
noreply@sarovar.org wrote:
See the patch file itself or the mailing list for actual usage and comments.
Here is the blurb from the top of the change file: 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 :-) Pawel, I hope this is what you had in mind. Taco
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 Martin -- http://www.tm.oneiros.de
Martin Schröder wrote:
On 2005-06-27 16:53:12 +0200, Taco Hoekwater wrote:
Very nice. I've added a call of init_randoms(random_seed) to "Implement \.{\\ptexsetrandomseed}"; this allows one to restart the random generator.
Cool. That was the intention all along, of course. Taco
Martin Schröder wrote:
And I've renamed the primitives to \ptexuniformdeviate, \ptexnormaldeviate, \ptexrandomseed and \ptexsetrandomseed.
i'm still not that satisfied with the p in there, since those are more generic extensions that pdftex only and we want them to end up in aleph and xetex as well (unless the p stands for 'primitive') (in which case \prim or \primitive would probably be a better prefix) [the ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
participants (4)
-
Hans Hagen
-
Martin Schröder
-
noreply@sarovar.org
-
Taco Hoekwater