The simplest approach is to draw a one to one correspondence between a
partition W into N integers and a binary sequence with (N-1) zero's and
W one's. The zero's then mark the boundaries of consecutive strings of
ones. For instance the sequence
01110111001
corresponds to the partition 03301 of 7.
So all you have to do is randomly choose a binary string which is dead
easy. For instance, you can just sample a population with (N-1) zero's
and W one's without replacement.
Here is some R-code. The population is P. The random binary string is x.
The rest is converting the string into the partition. Obviously you
could put this all into a single line:
P_c(rep(0,N-1),rep(1,W))
x_sample(P,length(P))
diff(c(0,(1:(N+W-1))[x==0],N+W))-1
Thanks to all those who replied.
Professor Chris J. Lloyd
Managing Editor ANZJS
Melbourne Business School, Ltd.
University of Melbourne
200 Leicester St, Carlton 3053
Ph: (613) 93498228
Fax: (613) 93498133
|