简体   繁体   English

使用R计算样本均值的概率

[英]Calculating the probability of a sample mean using R

I'm in an intro to stats class right now, and have absolutely no idea what's going on. 我现在正在介绍stats课程,并且绝对不知道发生了什么。 How would I solve the following problem using R? 我如何使用R解决以下问题?

Let x be a continuous random variable that has a normal distribution with a mean of 71 and a standard deviation of 15. Assuming n/N is less than or equal to 0.05, find the probability that the sample mean, x-bar, for a random sample of 24 taken from this population will be between 68.1 and 78.3, 令x是一个连续随机变量,其正态分布的平均值为71,标准差为15。假设n / N小于或等于0.05,则求出样本均值x-bar对于a的概率。从该人群中随机抽取的24个样本将在68.1和78.3之间,

I'm really struggling on this one and I still have to get through other problems in the same format. 我真的很努力地解决这个问题,但我仍然必须以相同的格式解决其他问题。 Any help would be greatly appreciated! 任何帮助将不胜感激!

For R coding this might set you up: 对于R编码,这可能会设置您:

[# Children's IQ scores are normally distributed with a
# mean of 100 and a standard deviation of 15. What
# proportion of children are expected to have an IQ between
# 80 and 120?

mean=100; sd=15
lb=80; ub=120

x <- seq(-4,4,length=100)*sd + mean
hx <- dnorm(x,mean,sd)

plot(x, hx, type="n", xlab="IQ Values", ylab="",
  main="Normal Distribution", axes=FALSE)

i <- x >= lb & x <= ub
lines(x, hx)
polygon(c(lb,x\[i\],ub), c(0,hx\[i\],0), col="red") 

area <- pnorm(ub, mean, sd) - pnorm(lb, mean, sd)
result <- paste("P(",lb,"< IQ <",ub,") =",
   signif(area, digits=3))
mtext(result,3)
axis(1, at=seq(40, 160, 20), pos=0)]

绘制示例数据

There is also some nice introductory course to R and data analysis by datacamp, this might also come in handy: https://www.datacamp.com/courses/exploratory-data-analysis 关于datacamp的R和数据分析也有一些不错的入门课程,这也可能派上用场: https ://www.datacamp.com/courses/exploratory-data-analysis

And another tutorial on R and statistics: http://www.cyclismo.org/tutorial/R/confidence.html 关于R和统计的另一篇教程: http : //www.cyclismo.org/tutorial/R/confidence.html

In terms of the code: 在代码方面:

pop_sample <- rnorm(24, 71, 15)
se_pop <- sd(pop_sample)/sqrt(24)
pnorm(78.3, 71, se_pop) - pnorm(68.1, 71, se_pop) # 80%

In term of stats... you should probably refer to stats.stackexchange.com or your professor. 在统计方面……您应该参考stats.stackexchange.com或您的教授。

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

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