如何在R中使用pnorm计算N个随机变量的均值小于给定值的概率 [英] How to use pnorm in R to calculate the probability that the mean of N random variables is less than a given value

查看:87
本文介绍了如何在R中使用pnorm计算N个随机变量的均值小于给定值的概率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 R 中,假设特定类型的计算器的寿命遵循正态分布,均值 = 5000 小时,SD = 500 小时.如果我必须随机选择一个计算器,那么它持续不到 4000 小时的概率是多少?

In R, lets say that the lifetime of a particular type of Calculator follows a normal distribution with Mean=5000 hours and SD = 500 hours. If I had to randomly choose a calculator, then what is the probability that it will last less than 4000 hours?

我在 R 中的计算如下 -

My calculation in R is as below -

pnorm(4000, mean=5000, sd =500)

[1] 0.02275013

我对概率为0.02275013的理解是否正确?

Is my understanding correct that the probability is 0.02275013?

接下来,假设随机抽取了 15 个计算器样本.平均寿命小于 4000 小时的概率是多少?我不知道如何在 R 中做到这一点?我所做的是

Next, lets say a random sample of 15 calculators is picked. What is the probability that the mean lifetime is less than 4000 hours? I am not sure how to do this in R? What I've done is

sample<-rnorm(15, mean = 5000, sd =500)
pop<-sd(sample/sqrt(15))
pnorm(4000, 4800, pop)

[1] 1.723545e-10

我的理解正确吗?

推荐答案

SO 用于编码问题.这不是一个编码问题.但我还是走了.

SO is for coding questions. This isn't much of a coding question. But here I go anyway.

我首先要指出 SO 的指导方针指出要求家庭作业帮助的问题必须包括您迄今为止为解决问题所做的工作的总结,以及对问题的描述你正在解决它的困难."我不确定这个问题 是否符合本指南,但它是一个重要的统计主题,所以让我们覆盖它.

I'll start by point out that SO's guidelines state "Questions asking for homework help must include a summary of the work you've done so far to solve the problem, and a description of the difficulty you are having solving it." I'm not sure this question [edit: the question as originally asked] meets this guideline, but it's an important stats topic, so let's cover it.

对于具有给定均值和标准差(此处为 5000)的正态分布,pnorm 返回累积概率高达 q(此处为 q=4000)是正确的和 500).所以是的,随机选择的计算器持续时间少于 4000 小时的可能性是 0.02275——也就是说,大约 2.3% 的计算器持续时间少于 4000 小时.

You are correct that pnorm returns the cumulative probability up to q (here q=4000) for a normal distribution with a given mean and standard deviation (here, 5000 and 500). So yes, the probably that a randomly chosen calculator lasts less than 4000 hours is 0.02275 -- that is to say that approximately 2.3% of calculators last less than 4000 hours.

然而,您的主要问题是关于 15 个随机选择的计算器的平均值.该统计量(均值)将具有概率分布.事实证明,N 个随机变量的均值均分布为 N(mu, sigma^2),并且每个均独立于其他随机变量具有具有相同期望 (mu) 和方差为 sigma^2/N 的正态分布.简而言之:

Your main question, however, is about the mean of 15 randomly chosen calculators. This statistic (the mean) will have a probability distribution. It turns out that the mean of N random variables each distributed N(mu, sigma^2) and each independent of the others has a normal distribution with the same expectation (mu) and a variance of sigma^2/N. In short:

  • 如果 X_i ~ N(mu, sigma^2) for i=1,...,N 并且它们是独立的
  • 然后表示 ~ N(mu, sigma^2/N)

所以在 R 中:

pnorm(4000, mean=5000, sd=500/sqrt(15))
# 4.742869e-15

这实际上为零.这是有道理的,因为随机抽样持续时间少于 4000 小时的单个计算器的可能性很低(只有 2.3%).随机抽样 15 个平均少于 4000 小时的计算器将非常倒霉,因此发生此类事件的可能性接近于零.

This is effectively zero. This makes sense because there is a low probably of randomly sampling a single calculator that lasts less than 4000 hours (only 2.3%). Randomly sampling 15 calculators that average less than 4000 hours would be extremely unlucky, and thus the probably of such an event is near zero.

这篇关于如何在R中使用pnorm计算N个随机变量的均值小于给定值的概率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆