Changes http://wiki.axiom-developer.org/227RandomIntegerIsAStrangeFunction/diff -- >Since I'm currently working in statistics and probability...
In that case, I completely agree with you on exactness whenever possible (depending on the computation and distribution involved). But those situations are rare (may be limited to only some discrete random variable with a finite sample space like the Binomial r.v.) I wonder how one can create even a normally distrihbuted random variable. In simulation programs involving a continuous random variable, uniformly distributed floats and the inverse of the cumulative distribution function are involved. How can you do any exact computations with continuous variables if you have to solve for the inverse of the cdf? You will need exact reals, and then an exact method to solve 'cdf(x)=y', for any uniformly distributed random real number 'y' over (0,1). Even for discrete variables like the Poission variable, you will have to use floats, or else you get into exact summations and their inverses. >But why wouldn't you use simply 'random(11)\$INT' ? Because I was not thinking or was stupid or both! Now that I believe I am thinking, using 'random(11)\$INT' simply passes the question to Lisp and if you are still picky, you should investigate how the Lisp function 'random(n)' is coded. Is it some variation of the usual linear congruence method, but perhaps extended to arbitrary precision with a large base like $2^{26}$ to cover really large 'n'. For small 'n', it would be modulo 'n' in the same way: that is, the algorithm for 'random(11)\$Lisp' may be actually something like 'random1(seed)$Lisp rem 11' translated to Lisp where 'random1' (name is arbitrarily made up) is the Lisp random number generator for single precision (4 byte, for example) integers and 'seed' is the seed or previously generated random single precision integer. If so, it would be only approximately uniform also. >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. The way to go would seem to be to create two new categories 'ProbabilityDensityFunctions' (or 'ProbabilityDensityFunctionSpace') and 'RandomVariable', say 'RandomVariable(S:Set, d:ProbabilityDensityFunction)' where 'S' is the sample space, and 'x:=random()' would mean 'x' is a r.v. on 'S' with probabillity density function 'd', and then create domains for these. The actual design, parameters, and specifications will need be more carefully thought out, say whether to use the cdf instead of the pdf (it seems cdf has lots of advantages as it is easy to recover the pdf by differentiation in many cases and cdf is continuous), and what are useful functions ( 'seed(x)', 'nextRandom(x)' come to mind, but operations on r.v. such as finding the pdf of joint distributions, are possible too). Then, if we were in Aldor, we can retroactively make 'IntegerNumberSystem' a subcategory (In Axiom, we add a package). This would be a major project, since as you know, probability theory gets g! eneralized into measure theory and so on. I think worrying about the proper syntax of 'random()' for an infinite sample space is the least of our (your?) problems :-) William -- forwarded from http://wiki.axiom-developer.org/[EMAIL PROTECTED] _______________________________________________ Axiom-developer mailing list Axiom-developer@nongnu.org http://lists.nongnu.org/mailman/listinfo/axiom-developer