[erlang-questions] process dictionary, anyone?

Per Hedeland per@REDACTED
Fri Apr 27 23:12:13 CEST 2007


Luke Gorrie <luke.gorrie@REDACTED> wrote:
>
>Robert Virding <robert.virding@REDACTED> writes:
>
>> I don't want to say it but RTFM. It's documented as well as how you 
>> initialise the seed. The algorithm used is quite good but not at all 
>> suitable for cryptography.
>
>Since you did say it :-) I checked TFM and it's not helpful.

Helpful or not, it does describe everything that people claimed to be
ignorant of so far in this thread.

>Most people calling random:uniform/1 will want a randomish number,

Did you take a survey?:-) In fact it's a standard and desirable property
of most "random" functions to produce the same number sequence whenever
you call them without seeding first (or with a specific seed) - cf e.g.
random(3) in a C library near you. A function that doesn't do this is
either a toy or geared specifically towards cryptography, which is of
course only one of many possible uses.

And as a programmer you should know that despite evidence to the
contrary, software can never produce random results, you need hardware
for that:-) - all software RNGs are pseudo-ditto, producing a "very
long" (but finite) cycle of "apparently random" (but entirely
predictable when the internal state is known) numbers. You just get to
choose the starting point, i.e. the seed. So the trick of getting "true"
randomness lies in appropriately using some appropriate hardware to get
a "good" seed.

As requirements on this varies wildly, it's not something the RNG should
do under the cover - in some cases you absolutely want the same sequence
every time (e.g. when debugging your statistical analysis tool), in
other cases you may be perfectly happy with the mostly crappy choice of
using erlang:now/0, in yet others you need something at least as good as
/dev/random (seeding is what it's for - though on Linux you'd better use
/dev/urandom unless you're prepared to have your program block
indefinitely), but the existence of this is OS-specific, etc etc.

>Possibly the referenced article in the 1982 Journal of Applied
>Statistics has an excellent explanation of how to produce your own
>seed and virtue of the constant provided by seed0(), but seriously!

A good (IMHO) and pretty compact writeup of the general issues can be
found in the FreeBSD random(4) man page:

http://www.freebsd.org/cgi/man.cgi?query=random&sektion=4#RANDOMNESS

--Per Hedeland



More information about the erlang-questions mailing list