2007 05 11

This presentation covers a general overview of the goals, origins, reasearch and tools currently available for the DISCUS project. For more information please visit the DISCUS project website.

2007 05 11

Sometimes you may need to sample a dataset. You may want to get a uniformly sampled subset out of a datatset stored in a file. The perlscript below does the job for you.


#!/usr/bin/perl -w
if ( $#ARGV!=1 ) {
        print "Wrong number of arguments\n\t".
                "uniform-sampler.pl <file> <sample_proportion>\n";
}
else {
        srand();
        open(FILE,$ARGV[0]) or die "File $ARGV[0] could not be open";
        while($line=<FILE>) {
                if ( rand()<$ARGV[1] ) {
                                print $line;
                }
        }
        close FILE;
}
1;