Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Randomly permute a given set of numbers
Date: Sun, 12 Sep 2010 18:22:03 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 10
Message-ID: <i6j5ob$i4i$1@fred.mathworks.com>
References: <i6hq95$fjn$1@fred.mathworks.com> <i6hsgb$3oh$1@fred.mathworks.com> <i6hu32$cb$1@fred.mathworks.com> <i6hv12$d5r$1@fred.mathworks.com> <i6i3n3$fff$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1284315723 18578 172.30.248.38 (12 Sep 2010 18:22:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 12 Sep 2010 18:22:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:669408

  Venkatesh didn't make it clear what relative frequencies are desired for the different nonzero row counts.  If each count is assumed to have an equal probability, one could simply do this:

 A = zeros(n,m);
 for k = 1:n
  p = randperm(m);
  q = 1:floor((m-1)*rand+2);
  A(k,p(q)) = q;
 end

Roger Stafford