axiom-developer
[Top][All Lists]

## [Axiom-developer] [#227 'random()\$Integer' is a strange function]

 From: kratt6 Subject: [Axiom-developer] [#227 'random()\$Integer' is a strange function] Date: Mon, 21 Nov 2005 03:15:40 -0600

```Changes
http://page.axiom-developer.org/zope/mathaction/227RandomIntegerIsAStrangeFunction/diff
--
I am proposing to keep 'random()' only for finite sets. In this case it should
return a random element uniformly chosen from all elements.

For infinite sets, we have - or should have - functions which chose a random
element chosen according to the distribution, indicated by the function
name. Of course, not all distributions make sense on all sets... But I'm
certain that this can be worked out.

However, I meanwhile realize that it can be very difficult to create a random
element according to the uniform distribution of some finite domain. This is
indeed a severe obstacle. I do not know whether this applies to any domain
currently in Axiom.

Since you think that I'm missing the point, here is an example: why don't we
define 'random()\\$INT' to be always equal to \$1783\$? Of course, it wouldn't
make much sense in practice, but it is indeed a random integer, with a rather
peculiar distribution maybe. I believe that such functions should not be used.

> > Furthermore, I think that lines like 'random()\\$Z rem 11' are a bad idea,
> > since the resulting distribution will be nearly uniform, but not quite...
> > Do you know why such code was written?

> You are getting really picky here!

Yes.

> just use something like 'random(11*(2^26 exquo 11))\\$INT rem 11' instead.

But why wouldn't you use simply 'random(11)\\$INT'?

> Unless you are thinking of applications in exact simulations for theoretical
> probability and statistics,

Since I'm currently working in statistics and probability...

Martin
--