--- Larry Wall <[EMAIL PROTECTED]> wrote: > On Mon, Jul 12, 2004 at 10:12:03AM -0700, Austin Hastings wrote: > : --- Dave Whipp <[EMAIL PROTECTED]> wrote: > : > : > rand(@x) == @x.rand == @x[ rand int @x ] == @x[ rand(1) * @x ] > : > > : > guaranteeing a uniform distribution unless adverbial modifiers > are > : > used. > > The hard part being to pick a random number in [0,Inf) uniformly. :-)
Half of all numbers in [0, Inf) are in the range [Inf/2, Inf). Which collapses to the range [Inf, Inf). Returning Inf seems to satisfy the uniform distribution requirement: if you have a number you're waiting to see returned, just wait a bit longer... > : Meaning I can do: > : > : $avg_joe = rand @students :bell_curve; > : > : ? > > Certainly you can do that, but it'll only work if some version of > rand declares either a ?$bell_curve option or a +$bell_curve option. > (And the latter will work only if we can extend multiple dispatch to > pay attention to named parameters, which we've explicitly put into > the category of things the Parrot folks are allowed to ignore for > 6.0.0.) Why is this a parrot-ism and not a P6-ism? The behavior of multiple dispatch, itself supposedly a tunable thing, seems likely to be a P6-internal rather than a Parrot thing. (In fact, I would think this is a simple behavior: discover the "rand" token, realize that there's a multi sub with that name, emit a MD call, keep going.) =Austin