Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re: inclusive rand

by vrk (Chaplain)
on Mar 13, 2017 at 17:09 UTC ( #1184450=note: print w/replies, xml ) Need Help??

in reply to inclusive rand

A bit of probability theory: if X has the Uniform(0,1) distribution, the support (range) is [0,1]. If the support is actually [0,1), then the distribution is actually Uniform(0, 1-epsilon) for some small epsilon. In this case, if you knew what epsilon is, you could scale by the width of the support to get Y = X/(1 - epsilon - 0) = X/(1 - epsilon) and Y would have true Uniform(0,1) distribution.

As others have pointed out, there are a number of factors involved and epsilon likely isn't just the machine epsilon or unit roundoff. Besides, even if it were, see pryrt's reply Re^6: inclusive rand. The figure in question is too small; on normal floating point hardware, dividing by 1-epsilon would be no different from dividing by 1.

Replies are listed 'Best First'.
Re^2: inclusive rand
by Lotus1 (Vicar) on Mar 13, 2017 at 18:34 UTC

    This finds the smallest difference between any two random values.

    use strict; use warnings; use List::MoreUtils qw(uniq); use List::Util qw(min); my @samples = sort { $a <=> $b } uniq map {rand} 1..3000; print scalar @samples, " unique samples.\n"; print "The minimum difference is ", min map { $samples[$_] - $samples[ +$_-1] } 1..$#samples; __END__ 2861 unique samples. The minimum difference is 3.0517578125e-005

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1184450]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (2)
As of 2023-02-05 21:24 GMT
Find Nodes?
    Voting Booth?
    I prefer not to run the latest version of Perl because:

    Results (33 votes). Check out past polls.