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$>
References: <jmde4t$hd4$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1334509747 24872 (15 Apr 2012 17:09:07 GMT)
NNTP-Posting-Date: Sun, 15 Apr 2012 17:09:07 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: comp.soft-sys.matlab:764563

"Siva " <> wrote in message <jmde4t$hd4$>...
> 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