SOLUTION BY R Give an efficient method for generating nine uniform points on (0,
ID: 3240636 • Letter: S
Question
SOLUTION BY R Give an efficient method for generating nine uniform points on (0, 1) conditional on the event than no two of them are within 0.1 of each other. (It can be shown that if n points are independent and uniformly distributed on (0, 1), then the probability that no two of them are within d of each other is, for 0 < d < 1/(n 1), [1- (n-1)d]n.) SOLUTION BY R Give an efficient method for generating nine uniform points on (0, 1) conditional on the event than no two of them are within 0.1 of each other. (It can be shown that if n points are independent and uniformly distributed on (0, 1), then the probability that no two of them are within d of each other is, for 0 < d < 1/(n 1), [1- (n-1)d]n.)Explanation / Answer
x=runif(1,0,1)
count=0
while(count < 9)
{
y=runif(1,0,1)
if(abs(x-y)>=0.1)
{count=count+1
print(y)
x=y}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.