Question
Use R to solve this
Thank for your help
3· [Additional problem only for graduate students. Undergraduate students will receive 2 extra credits if solving the additional problems correctly.l (5 points) For each of p 50, 100, 500, 1000, randomly drawn 10000 pairs of indepen dent points uniform in the cube in p-space, [0, 1]P. Then for each pair of two points calculate the distance. Use the n distances to calculate the ratio 25th percentile of the distances 75th percentile of the distances Simulate the process for s = 1000 times to obtain ri, r2: ,r, and make 95% confidence limit of the ratios for each p. Draw a plot to show the pattern of the 95% confidence limits when P increases and explain. Note that 95% confidence limit is the interval of (2.5th percentile, 97.5th percentile)
0 0
Add a comment Improve this question Transcribed image text
Answer #1

##R code

Upper_quantile=numeric(4)
lower_quantile=numeric(4)
p=c(50,100,500,1000)
for(k in 1:4){
r=numeric(1000)
for(s in 1:1000){
dist=numeric(10000)
for(i in 1:10000){
x=runif(p[k])
y=runif(p[k])
dist[j]=(sum((x-y)^2))^(1/2)
}
r[s]=quantile(dist,prob=0.25)/quantile(dist,prob=0.75)
  
}
Upper_quantile[k]=quantile(r,prob=0.025)
lower_quantile[k]=quantile(r,prob=0.975)
}

plot(p,Upper_quantile,type="l",col="red",ylab="Upper and lower quantile")
lines(p,lower_quantile,col="blue")

Upper and lower quantile 0.90 0.94

Add a comment
Know the answer?
Add Answer to:
Use R to solve this Thank for your help 3· [Additional problem only for graduate students....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT