My private response to Melina
was that I didn't think the distribution she described was well defined.
The way described below is valid most of the time, but not the only
way. For example, another way to generate RNs separated by more than c
(I'm not recommending this) would be to create a larger sample (N) than
needed (n), recursively remove one (or both) of any neighboring pair
that has a separation greater than c. If the result, satisfying the c
constraint, has >n numbers, randomly remove the extras. If it has
<n, try again, perhaps increasing N. I'm not sure whether the
distribution obtained this way is the same distribution as obtained by
the method below.
In any case, the distribution will depend on the relationship of n, c,
and the range. And there are boundary problems. For example, the
method below can fail if n=2, c=0.8, the range is (0,1), and the first
value sampled is near 0.5.
So again, since the problem is not well defined, different solutions
may result in different distributions. The problem needs to be taken
up a level -- why is such a random sample needed?
Alan Gross
David L Lorenz wrote:
Melina,
Sorry again. I just remembered that the method that I have seen
recommended for this particular problem is to sequentially add random
numbers that satisfy the separation criterion. This is not efficient in
terms of S+ programming. But, I believe that it produces a distribution
that is more nearly uniform in distribution.
Here's a snippet of code that generates 6 random numbers separated by at
least 1 on a uniform distribution from 0 to 10:
x3.1 <- runif(1,0,10)
for(j in 2:6) {
x3.2 <- runif(1,0,10)
while(min(diff(sort(c(x3.1, x3.2)))) < 1)
x3.2 <- runif(1,0,10)
x3.1 <- c(x3.1, x3.2)
}
Dave
"David L Lorenz"
<lorenz@usgs.gov> To: carcappe@unina.it
Sent by: cc: s-news@lists.biostat.wustl.edu,
s-news-owner@lists.biosta s-news-owner@lists.biostat.wustl.edu
t.wustl.edu Subject: Re: [S] sampling from an uniform with a minimum distance between
the
11/22/2004 09:47 AM
Melina,
I am not sure that this simple approach gives a uniform distribution. I
believe that the random numbers that are selected using that procedure
results in a higher number of values that are close to the limits of the
distribution. This effect is more pronounced as the spacing gets to be a
larger proportion of the limits of the distribution. If it is very small,
then the effect is negligible.
Sorry, I do not have an unbiased method.
Dave
carcappe@unina.it
Sent by: To:
s-news@lists.biostat.wustl.edu
s-news-owner@lists.biosta cc:
t.wustl.edu Subject: [S]
sampling from an uniform with a minimum distance between the
sampled values
11/21/2004 10:59 AM
Many thanks to Henrik Nielsen, James Hotlman, Simon Rosenfeld and Alan
Gross
for replaying to my message.
A special thank to Juhlin Kenton and Greg Snow who gave me the right hint
to
sort the problem out.
the right script is
if (min(range(diff(sort(x))))<c)
melina
Carmela Cappelli
Department of Statistics, School of Political Science
University of Naples Federico II
phone: +39-081-2537553
fax:+39-081-2537466
----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
--------------------------------------------------------------------
This message was distributed by s-news@lists.biostat.wustl.edu. To
unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
the BODY of the message: unsubscribe s-news
--------------------------------------------------------------------
This message was distributed by s-news@lists.biostat.wustl.edu. To
unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
the BODY of the message: unsubscribe s-news
--------------------------------------------------------------------
This message was distributed by s-news@lists.biostat.wustl.edu. To
unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
the BODY of the message: unsubscribe s-news
|
|