Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Sampling from Combination Space

by Zaxo (Archbishop)
on Jul 18, 2005 at 06:02 UTC ( [id://475648]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    use List::Util qw/shuffle/;
    sub pick {
        return if @_ != 2;
        my ($num, $count) = @_;
        (shuffle 1 .. $num)[0 .. $count-1];
    }
    
  2. or download this
    my ($top, $ct, @samples) = (158, 8);
    my $size = 50,000;
    
    $#samples = $size;
    $_ = [pick( $top, $ct)] for @samples;
    
  3. or download this
    my %sample;
    $sample{join ',', pick($top, $ct)} = undef
        while $size > keys %sample;
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2024-04-24 05:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found