Path: news.mathworks.com!not-for-mail From: <HIDDEN> Newsgroups: comp.soft-sys.matlab Subject: Re: Random sampling with constraints Date: Sun, 15 Apr 2012 17:09:07 +0000 (UTC) Organization: The MathWorks, Inc. Lines: 6 Message-ID: <jmevbj$o98$1@newscl01ah.mathworks.com> References: <jmde4t$hd4$1@newscl01ah.mathworks.com> Reply-To: <HIDDEN> NNTP-Posting-Host: www-04-blr.mathworks.com Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: newscl01ah.mathworks.com 1334509747 24872 172.30.248.35 (15 Apr 2012 17:09:07 GMT) X-Complaints-To: news@mathworks.com NNTP-Posting-Date: Sun, 15 Apr 2012 17:09:07 +0000 (UTC) X-Newsreader: MATLAB Central Newsreader 1187260 Xref: news.mathworks.com comp.soft-sys.matlab:764563 "Siva " <sivaathome@gmail.com> wrote in message <jmde4t$hd4$1@newscl01ah.mathworks.com>... > I have a random [ 1 x m] vector of unique integers P. I need to randomly generate a [ 1 x n] vector S that is a subset of P that satisfies the requirement that the difference between any two integers in S is greater then "d". - - - - - - - - - - If you wish to strictly avoid all bias in your random selection of S, I think in a problem of this nature it might very well be necessary to compute a list of all possible solutions and then randomly select one of them from that list. If P and S are large and d is small, doing so could lead to an immense list of possible solutions, so this would be a rather desperate undertaking. It is important that you perform the initial sorting operation. Having done that I can envision a recursion process that has depth n (the number of elements to be placed in S) in which all possible solutions are found without repetition. Are you sufficiently determined in avoiding bias to undertake such a method, or would some simpler heuristic method be adequate? Roger Stafford