Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
计算R中向量间隔的中值_R_Probability_Median_Usage Statistics - Fatal编程技术网

计算R中向量间隔的中值

计算R中向量间隔的中值,r,probability,median,usage-statistics,R,Probability,Median,Usage Statistics,我面临以下挑战: 设X是在区间[1,10]上均匀分布的V.a.离散。多愁善感 另一个V.A.每个Y样本由1的中值给出 一套10个样品。生成10^6个Y样本 我使用的是R,代码如下: x <- runif(10000000,1,10) sample <- cut(x,breaks=10) y = median(sample) x你可以做: mosaic::median(~x|sample) 或在R基中: tapply(x, sample, median) 我不知道那件事。谢谢

我面临以下挑战: 设X是在区间[1,10]上均匀分布的V.a.离散。多愁善感 另一个V.A.每个Y样本由1的中值给出 一套10个样品。生成10^6个Y样本

我使用的是R,代码如下:

x <- runif(10000000,1,10)
sample <- cut(x,breaks=10)
y = median(sample)
x你可以做:

 mosaic::median(~x|sample)
或在R基中:

 tapply(x, sample, median)

我不知道那件事。谢谢分享