【问题标题】:R - generating a random sample [duplicate]R - 生成随机样本
【发布时间】:2021-03-11 14:56:29
【问题描述】:

我无法弄清楚如何执行以下操作:

为均值为 250、方差为 625 (SD 25) 的正态分布随机变量 X 生成图。

从均值 = 10 方差 = 400 的正态分布变量 Z 生成随机样本 (n=15)。使用此样本估计 Z 的总体均值和 95% 置信区间。

基本上我正在努力的主要部分是生成随机样本/变量。谢谢!

【问题讨论】:

标签: r statistics


【解决方案1】:

rnorm(n=15,mean=10,sd=sqrt(400)) 函数将为您提供想要的数字...

【讨论】:

    【解决方案2】:

    rnorm() 函数从正态分布中抽取随机样本。

    来自normal distribution page in the R manual

    rnorm(n, mean = 0, sd = 1)
       
       n:    number of observations. If length(n) > 1, the 
               length is taken to be the number required.
       mean: vector of means.
       sd:   vector of standard deviations.
    

    因此,如果您需要 15 次平均 250 和 sd 25 的平局,rnorm(15, 250, 25)

    [1] 250.0760 251.0984 201.1045 231.8379 213.2640 263.3968 274.8070 225.1520
    [9] 260.0468 275.5306 295.3408 241.8458 229.2726 285.6786 232.1860
    

    【讨论】:

      猜你喜欢
      • 2014-05-18
      • 1970-01-01
      • 1970-01-01
      • 2020-09-08
      • 1970-01-01
      • 2013-06-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多