ysth has asked for the wisdom of the Perl Monks concerning the following question:
If I just loop through, giving each element a chance to be set of (how many ones left to assign) over (how many elements are left), it seems to me that that will distort the distribution toward the end.
Update: Many thanks to all who replied. What I was looking for was a random distribution, not an even distribution, and with a total of M, not an total averaging M, determined sequentially. Abigail-II's answer fits. Using the List::Util::shuffle to prepare a sequence and pulling elements off of it as I go through the real data also would fit the bill.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: random elements with fixed totals
by BrowserUk (Patriarch) on Nov 16, 2003 at 03:07 UTC | |
|
Re: random elements with fixed totals
by Abigail-II (Bishop) on Nov 16, 2003 at 03:12 UTC | |
by ysth (Canon) on Nov 16, 2003 at 07:21 UTC | |
|
Re: random elements with fixed totals
by Zaxo (Archbishop) on Nov 16, 2003 at 05:26 UTC | |
|
Re: random elements with fixed totals
by jonadab (Parson) on Nov 16, 2003 at 12:59 UTC | |
|
Re: random elements with fixed totals
by pg (Canon) on Nov 16, 2003 at 04:05 UTC | |
by ysth (Canon) on Nov 16, 2003 at 06:53 UTC | |
|
Re: random elements with fixed totals
by CountZero (Bishop) on Nov 16, 2003 at 21:59 UTC |