Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^2: inclusive rand

by Lotus1 (Priest)
on Mar 13, 2017 at 18:34 UTC ( #1184463=note: print w/replies, xml ) Need Help??


in reply to Re: inclusive rand
in thread inclusive rand

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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2018-08-19 13:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Asked to put a square peg in a round hole, I would:









    Results (186 votes). Check out past polls.

    Notices?