简体   繁体   中英

Calculate Proportion in R using Normal Distribution

I was working on statistics using R. Before i do this using R program, i have done it manually. So here is the problem.

A sample of 300 TV viewers were asked to rate the overall quality of television shows from 0 (terrible) to 100 (the best). A histogram was constructed from the results, and it was noted that it was mound-shaped and symmetric, with a sample mean of 65 and a sample standard deviation of 8. Approximately what proportion of ratings would be above 81?

I have answered it manually with this : Pr(X>81)=Pr(Z>(81-65)/8)=Pr(Z>2)=0.0227 So the proportion is 0.023 or 2.3%

I have trouble with how can i do this in R ? I have tried using pnorm(p=..,mean=..,sd=..) but didnt find similar result with my manual. Thank you so much for the answer

You identified the correct function.

The help on pnorm gives the list of arguments:

 pnorm(q, mean = 0, sd = 1, lower.tail = TRUE, log.p = FALSE)

with the explanation for the arguments:

       x, q: vector of quantiles.
       mean: vector of means.
         sd: vector of standard deviations.
 log, log.p: logical; if TRUE, probabilities p are given as log(p).
 lower.tail: logical; if TRUE (default), probabilities are P[X <= x]
              otherwise, P[X > x].

Under "Value:" it says

... ‘pnorm’ gives the distribution function,

So that covers everything. If you put the correct value you want the area to the left of in for q and the correct mu and sigma values, you will get the area below it. If you want the area above, add lower.tail=FALSE .

Like so:

 pnorm(81,65,8)  # area to left
 [1] 0.9772499

 pnorm(81,65,8,lower.tail=FALSE)  # area to right ... which is what you want
 [1] 0.02275013

(this way is more accurate than subtracting the first thing from 1 when you get into the far upper tail)

Edit: This diagram might clarify things:

在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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