Path: news.mathworks.com!not-for-mail
From: "Bruno Luong" <b.luong@fogale.findmycountry>
Newsgroups: comp.soft-sys.matlab
Subject: Re: k (3) Vectors of ones and zeros "combining" together
Date: Wed, 18 Jan 2012 13:02:08 +0000 (UTC)
Organization: FOGALE nanotech
Lines: 13
Message-ID: <jf6fsg$8cu$1@newscl01ah.mathworks.com>
References: <jf510f$nv5$1@newscl01ah.mathworks.com> <jf51ot$q13$1@newscl01ah.mathworks.com> <jf5309$a8$1@newscl01ah.mathworks.com> <jf59tg$jbs$1@newscl01ah.mathworks.com> <jf5b6o$n2p$1@newscl01ah.mathworks.com> <jf5re5$9lp$1@newscl01ah.mathworks.com> <jf5rpc$ah4$1@newscl01ah.mathworks.com> <jf6duk$2gh$1@newscl01ah.mathworks.com>
Reply-To: "Bruno Luong" <b.luong@fogale.findmycountry>
NNTP-Posting-Host: www-06-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1326891728 8606 172.30.248.38 (18 Jan 2012 13:02:08 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 18 Jan 2012 13:02:08 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 390839
Xref: news.mathworks.com comp.soft-sys.matlab:755033

"Roger Stafford" wrote in message <jf6duk$2gh$1@newscl01ah.mathworks.com>...
> "Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <jf5rpc$ah4$1@newscl01ah.mathworks.com>...
> > Can you elaborate Roger? It can't feel how the non-equal probability would be possible.
> - - - - - - - - - -
>   Hi Bruno.  Now I can say with certainty that the probabilities are _not_ equal.  In the case of N = 5, with the algorithm I used, randperm will select each of the 120 permutations with equal probability.  However there are only 60 permutations involving the first 3 elements.  A permutation (swap) between the last 2 elements does not affect the statistics of the ceil(3*rand(1,N-3)) action, so it would be equivalent to assume that we are using only the first three elements of randperm and taking the remaining 2 in ascending order.  For each of these 60 permutations then, there are 9 possible outcomes of ceil(3*rand(1,N-3)), of which 3 choose the same value and 6 choose different values.  That means of a total of 60*9 equally likely events, 60*3 will be distributed equally over 60 known partitions of the 1+1+3 type and 60*6 will be distributed equally over 90 known partitions of the 
1+2+2 
> type.  This gives a 1/180 probability for each of the first type and 1/135 for each of the second type.  The sampling runs I made earlier did in fact indicate the correct probabilities.  QED 

I see. Thank Roger for showing the drawback.

Perhaps that analysis shows the way to fix the original algorithm.

Bruno