in reply to Sampling from Combination Space
I have an interesting suggestion.
To generate a sampling, you just repeat the following steps:
After this process, the variable $count contains the number of random number you used to reach 158, which can be considered as number of selections.
Repeat above process and you will get the satistics. Refine this a little bit and pick the right m, will give you soem good enough simulation. You have to refine this.
Here is some code to illustrate this:
use strict; use warnings; my @counts; while (1) { my $count = 0; my $sum = 0; while (1) { $sum += rand(rand(rand(rand(158))));#need to refine print "$sum\n"; ($sum <= 158) ? $count ++ : last; } $counts[$count] ++; print "choose $count\n"; sleep 1; }
|
|---|