简体   繁体   English

具有方差1的离散均匀随机变量

[英]Discrete uniform random variable having variance 1

I would like to plot in R a discrete uniform random variable having variance 1, with an interval of [-a,a]. 我想在R中绘制一个方差为1且间隔为[-a,a]的离散均匀随机变量。

I have tried using Var(X)= (n^2-1)/12 我尝试使用Var(X)=(n ^ 2-1)/ 12

Then getting that n should be n = sqrt(13) 然后得到n应该是n = sqrt(13)
Plugging this into 将其插入

n=b-a+1=a-(-a)+1 N = B-A + 1 = - ( - A)+1
a=(sqrt(13)-1)/2 = 1.302776 a =(sqrt(13)-1)/ 2 = 1.302776

Trying this in R with the code 用代码在R中尝试

X <- sample(-1.302276:1.30227,1000, replace=TRUE)

The variance becomes around 0.65 方差约为0.65

The variance of a uniform distribution between a and b is (b - a) * (b - a) / 12 . ab之间的均匀分布的方差为(b - a) * (b - a) / 12

Therefore, for the interval [-a, +a] to have a variance of 1, you need to set 因此,对于间隔[-a, +a]的方差为1,您需要设置

a = sqrt(3)

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

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