From: "Bruno Luong" <b.luong@fogale.findmycountry>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Random Integers Within Specfic Ranges
Date: Sat, 12 Mar 2011 14:53:04 +0000 (UTC)
Organization: FOGALE nanotech
Lines: 10
Message-ID: <ilg1cg$r6q$>
References: <ildgd8$dhl$> <ilfv5b$6pa$>
Reply-To: "Bruno Luong" <b.luong@fogale.findmycountry>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1299941584 27866 (12 Mar 2011 14:53:04 GMT)
NNTP-Posting-Date: Sat, 12 Mar 2011 14:53:04 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 390839
Xref: comp.soft-sys.matlab:715378

"Derek O'Connor" wrote in message <ilfv5b$6pa$>...

> If m is approx. equal to n then this method is optimal. If m is much smaller than n then there are two obvious inefficiencies: (1) a vector p of size n is used, and (2) the for-loop takes n-1 steps.

Storing full p seems to be unavoidable in Roger's method.
The point (2) is not a point, just iterate m time then stop.