On Fri, 2004-07-16 at 12:10 -0400, Jonadab the Unsightly One wrote: > Austin Hastings <[EMAIL PROTECTED]> writes: > > > Half of all numbers in [0, Inf) are in the range [Inf/2, Inf). Which > > collapses to the range [Inf, Inf). > > It's not that simple. By that reasoning, 10% of all numbers in > [0,Inf) would be in [Inf/10,Inf), also reducing to the range > [Inf,Inf).
As a lurking mathematician on the list, I thought that it might be insightful to offer some comments at this point. Apologies in advance if I'm repeating something that happened at the beginning of the thread. Once you start talking about non-finite sets of numbers, percentages start to become amusingly meaningless. Classic examples: the set of integers and the set of positive integers have the same size; there are as many points on the perimeter of a square as there are in its interior. For many of the same underlying reasons, it's quite impossible to have a flat random probability distribution across the integers (or reals, for that matter). Hardware people are lazy, and have given us only a finite number of bits to work with. So, that gives us an excuse to be lazy as well in the non-Bignum case: if the list is known in advance to be infinite, then we just take C<rand(@x)> to be a flat distribution over the range of the double, or whatever Perl is using for such things. It's not like people will be able to access any other elements in the array ;-). If the array size is unknown, and the programmer doesn't want to risk accidental heat death, I see no problem with C<rand(@x,$lower,$upper)> for those cases; i.e., if the size of the array appears to be larger than abs($lower) and abs($upper), then we fall back to using those limits. People using C<rand(Inf)> with Bignums deserve to be spanked. :) A graceful solution in that case would be to interpret that as C<tan(rand (pi/2))*exp(pi*tan(rand(pi)))>, or better yet, C<tan(rand(pi))*exp (pi*tan(rand(pi)))>, since that roughly reflects what humans will do when you ask them for a random real number (mouth off some random digits and multiply by a "random" power of 10). Besides, there's always C<abs> if people can't stomach C<rand(Inf)> returning negative numbers. If they're using Bignums, they also ought to be savvy enough to figure out some other distribution if desired.* Peter *If people think C<rand(Inf)> should only return positive things, I'm fine with that. It's just annoying to have to type C< * (int(rand (2))*2-1)>.