Hi All, a couple of months ago I was asked to implement a simple random number generator in TeX. It is not very hard for uniform distributions, but I couldn't find satisfactory way to make it reliable and expandable. The problem is that all generators I know (I'm not expirienced in that stuff) use recently generated random number to make another one. For TeX it means we need to make an assignment. OK, there is no many practical reasons for that (: I've found two however. * if \pdfuniquresname is in use, one may want to make his own named resources unique as well * when playing i.e. with page backgrounds or other TeX-based pictures, it might be nice to have a possibility to use random text size/color/position. How do you think? Taco? -- Pawe/l Jackowski P.Jackowski@gust.org.pl
Pawel Jackowski wrote:
Hi All,
a couple of months ago I was asked to implement a simple random number generator in TeX. It is not very hard for uniform distributions, but I couldn't find satisfactory way to make it reliable and expandable. The problem is that all generators I know (I'm not expirienced in that stuff) use recently generated random number to make another one. For TeX it means we need to make an assignment.
In ConTeXt I use Donald Arseneau's plain tex random.tex. It's normally ok (esp if we'd have a milliseconds counter)
OK, there is no many practical reasons for that (: I've found two however. * if \pdfuniquresname is in use, one may want to make his own named resources unique as well * when playing i.e. with page backgrounds or other TeX-based pictures, it might be nice to have a possibility to use random text size/color/position.
Hans ----------------------------------------------------------------- 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 -----------------------------------------------------------------
Hi Hans,
In ConTeXt I use Donald Arseneau's plain tex random.tex. It's normally ok (esp if we'd have a milliseconds counter)
Indeed, I've also excerpted some things from random.tex. It works fine but primitives makes TeX world so smooth -) Thanks, -- Pawe/l Jackowski P.Jackowski@gust.org.pl
Pawel Jackowski wrote:
How do you think? Taco?
Sorry, I haven't asked the question precisely. What do you think about random numbers available as a pdfTeX primitive?
It would be easy to port metafont's random code, but I'm not sure if that is random enough for your (it was state of the art, but that was a quarter of a century ago). I'll create a change file to show you (hopefully today) Taco
Taco Hoekwater wrote:
Pawel Jackowski wrote:
How do you think? Taco?
Sorry, I haven't asked the question precisely. What do you think about random numbers available as a pdfTeX primitive?
It would be easy to port metafont's random code, but I'm not sure if that is random enough for your (it was state of the art, but that was a quarter of a century ago). I'll create a change file to show you (hopefully today)
not random enough indeed (for fast runs); this is why i let an external app generate the random number if it really needs to be random Hans ----------------------------------------------------------------- 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 -----------------------------------------------------------------
Hans Hagen wrote:
It would be easy to port metafont's random code, but I'm not sure if that is random enough for your (it was state of the art, but that was a quarter of a century ago). I'll create a change file to show you (hopefully today)
not random enough indeed (for fast runs);
In pdftex we have microseconds available these days :-) Taco
participants (3)
-
Hans Hagen
-
Pawel Jackowski
-
Taco Hoekwater