Hi All,
How to tackle these questions in R:

  1. In a certain population, the number of HP carriers is equal to 70 %. 7 persons were drawn from this population. What is the probability that:
    a. Exactly 2 of them would be carriers ?
    b. Maximum 3 persons would be carriers ?
    c. A person that was drawn as first would be a carrier, but the rest would not ?

  2. In a certain population aged 40 - 50 where a blood pressure is equal to 135 -155 mmHg it was concluded that sport activity prevents from heart attack episodes. It turned out that probability of preventing ha episodes is equal to 60 %.
    What is a probability that:
    a. sport activity would protect 8 out of 10 persons from ha episodes ?
    b. sport activity would protect at least 4 persons from this population ?

Any help would be much appreciated.

Hi,

Please have a look to our homework policy, homework inspired questions are welcome but they should not include verbatim instructions from your course.

Hi @andresrcs,

this is neither my homework nor an assignment from any course, however it might look like it.
After some time, I found the solution with a help of my colleague. I am presenting it below maybe for someone who would like to benefit from it. I would be very grateful for more examples how to calculate probability in R, as I am still confused about "n" and "x" and "size" arguments in those functions, so more real life examples would be helpful. Thanks.


### Answers:
### 1. 

p1 <- 0.7

n1 <- 7

#a) 
dbinom(2, size = n1, prob = p1)
#> [1] 0.0250047

#b)
pbinom(3, size = n1, prob = p1)
#> [1] 0.126036

#c) 

p1*(1-p1)^(n1-1)
#> [1] 0.0005103


### 2. 
p <- 0.6

n <- 10

#a)
dbinom(8, size = n, prob = p)
#> [1] 0.1209324

#b)
1-pbinom(3, size = n, prob = p)
#> [1] 0.9452381

Created on 2019-12-16 by the reprex package (v0.3.0)

Thank you @Yarnabrina for your kind and detailed explanation.
Additionally, I gathered some probability examples:

rbinom(100,5,0.5)
#>   [1] 3 2 2 4 3 4 3 3 4 2 1 3 3 5 3 3 1 2 2 1 3 4 5 3 4 1 3 2 1 3 2 1 3 1 4 3 3
#>  [38] 3 3 4 3 4 2 4 3 3 3 2 1 1 4 2 2 1 4 2 2 5 2 1 2 4 5 3 3 2 1 3 3 4 3 2 0 3
#>  [75] 3 2 4 2 3 5 2 2 0 3 5 1 2 4 3 2 2 3 4 1 1 4 3 3 4 3

Created on 2019-12-20 by the reprex package (v0.3.0)

"In the above, we have 100 samples of size 5, each with a probability of success of

0.5. It is as though I give a fair coin to each of 100 students and tell each one to

toss the coin 5 times and record the number of heads (successes).

Reference: https://github.com/RobinHankin/stat601"

My comment: this is somewhat confusing, because we have got here sample size of 5 trials not number of counts. Usually when we talk about sample size, it means some number of individual samples measured or observations used in a survey or experiment. It can be easily mistaken with 100 students - that normally would be called a simple size. So not very intuitive function's argument name here - sample size = 5.

"Suppose we have a binomial distribution with size 12 and probability 1/3, and we want to calculate the probability of observing 4 successes.
Reference: https://github.com/RobinHankin/stat601"

dbinom(4,12,1/3)
#> [1] 0.238446

Created on 2019-12-20 by the reprex package (v0.3.0)

In some group of people the average body weight was 65 Kilograms (SD=7). It was assumed that body weight distribution is normal. When carrying out screening examination among adults, the probability was calculated, that a person who will participate in this study will have a body weight < 66 Kilograms. How was it done?

pnorm(66, mean=65, sd = 7)
#> [1] 0.5567985

Created on 2019-12-20 by the reprex package (v0.3.0)

obraz

"Assume that the test scores of a college entrance exam fits a normal distribution. Furthermore, the mean test score is 72, and the standard deviation is 15.2. What is the percentage of students scoring 84 or more in the exam? We apply the function pnorm of the normal distribution with mean 72 and standard deviation 15.2. Since we are looking for the percentage of students scoring higher than 84, we are interested in the upper tail of the normal distribution.
Reference: http://www.r-tutor.com/elementary-statistics/probability-distributions/normal-distribution"

pnorm(84, mean=72, sd=15.2, lower.tail=FALSE) 
#> [1] 0.2149176

Created on 2019-12-20 by the reprex package (v0.3.0)

My comment: please note the difference between:
a) pnorm(84, mean=72, sd=15.2, lower.tail=FALSE)
b) pnorm(84, mean=72, sd=15.2)

Good read:
https://www.jaredlander.com/2013/12/drawing-balls-from-an-urn/

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.