简体   繁体   English

涉及均匀分布的概率

[英]Probability involving Uniform Distribution

Using R, I am instructed to generate 1000 random numbers in between 0 and 1, which I did using runif (1000). 使用R,我被指示生成0到1之间的1000个随机数,这是我使用runif(1000)完成的。 Then I am told to approximate the probability of the random number being in between 0.4 and 0.6. 然后,我被告知要估计随机数在0.4到0.6之间的概率。 I am new to R and would love any help. 我是R的新手,希望获得任何帮助。 Thanks. 谢谢。

You can do it like that: 您可以这样做:

a= runif(1000)
d= a > 0.4 & a < 0.6
sum(d)/1000

The last line is the approximated probability. 最后一行是近似概率。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM