Topic 3: Probability and Distributions


These are the solutions for Computer Lab 4.


1 jamovi modules and using the Rj editor in jamovi

No solutions required.

2 Using the norm R functions

Example R code is shown in the questions below, where relevant.

2.1 pnorm

No answer required.

2.1.1

We could verify this value using:

round(pnorm(1.5, mean = 0, sd = 1), 4)
## [1] 0.9332

2.1.2

No answer required.

2.1.3

pnorm(2, mean = 0, sd = 1)
## [1] 0.9772499
pnorm(-1, mean = 0, sd = 1)
## [1] 0.1586553
pnorm(1, mean = 2, sd = 1)
## [1] 0.1586553

Notice that the result is the same as for b, because we have shifted our curve two units to the right (so it is now centred at 2 rather than 0) but the spread has not changed.

pnorm(1, mean = 0, sd = sqrt(2))
## [1] 0.7602499
pnorm(2, mean = 0, sd = sqrt(3)) - pnorm(1, mean = 0, sd = sqrt(3))
## [1] 0.1577449
pnorm(1, mean = 0, sd = 2) - pnorm(-1, mean = 0, sd = 2)
## [1] 0.3829249

Note here that we could use the alternate approach below, which makes use of the symmetry property.

1- 2 * pnorm(-1, mean = 0, sd = 2)
## [1] 0.3829249
1 - pnorm(2, mean = 0, sd = sqrt(5))
## [1] 0.1855467

Note here that we are using the complement rule.

1 - pnorm(-1, mean = 0, sd = 3)
## [1] 0.6305587

Note here that we are using the complement rule.

pnorm(-2, mean = 0, sd = 1) + (1 - pnorm(2, mean = 0, sd = 1))
## [1] 0.04550026

Note here that we could use the alternate approach below, which makes use of the symmetry property.

2 * pnorm(-2, mean = 0, sd = 1)
## [1] 0.04550026

2.2 qnorm

No answer required.

2.2.1

round(qnorm(0.9772499, mean = 0, sd = 1), 2)
## [1] 2
qnorm(0.5, mean = 0, sd = 1)
## [1] 0
round(qnorm(0.7733726, mean = 0, sd = 1), 2)
## [1] 0.75
round(qnorm(0.2742531, mean = 1, sd = 1), 2)
## [1] 0.4
round(qnorm(0.7421539, mean = 3, sd = sqrt(2)), 2)
## [1] 3.92

3 Using the binom R functions

3.1 Playing Cards Example

No answer required.

3.2 The Binomial Distribution

No answer required.

3.3 Overview of binom R functions

No answer required.

3.4 dbinom

The probability of guessing correctly exactly once out of ten guesses is

dbinom(1, 10, 0.25)
## [1] 0.1877117

3.4.1

We have

The probability of making zero correct guesses out of ten guesses is

dbinom(0, 10, 0.25)
## [1] 0.05631351

The probability of guessing correctly exactly twice out of ten guesses is

dbinom(2, 10, 0.25)
## [1] 0.2815676

The probability of guessing correctly exactly three times out of ten guesses is

dbinom(3, 10, 0.25)
## [1] 0.2502823

The probability of guessing correctly exactly nine times out of ten guesses is

dbinom(9, 10, 0.25)
## [1] 2.861023e-05

The probability of guessing correctly exactly ten times out of ten guesses is

dbinom(10, 10, 0.25)
## [1] 9.536743e-07

We notice that (as expected) the probability associated with a high number of successes is lower.

3.5 pbinom

We have:

pbinom(6, 10, 0.25)
## [1] 0.9964943
pbinom(3, 10, 0.25)
## [1] 0.7758751
1 - pbinom(3, 10, 0.25)
## [1] 0.2241249
1 - pbinom(8, 10, 0.25)
## [1] 2.95639e-05
pbinom(8, 10, 0.25) - pbinom(6, 10, 0.25)
## [1] 0.003476143

Note that for e, since the Binomial distribution is a discrete distribution, we could also have used dbinom here, i.e. dbinom(7, 10, 0.25) + dbinom(8, 10, 0.25).

pbinom(6, 10, 0.25)
## [1] 0.9964943
pbinom(5, 10, 0.25)
## [1] 0.9802723

You could use either

1 - pbinom(8, 10, 0.25)
## [1] 2.95639e-05

or

dbinom(9, 10, 0.25) + dbinom(10, 10, 0.25)
## [1] 2.95639e-05

Again, you could use either

1 - pbinom(7, 10, 0.25)
## [1] 0.000415802

or

dbinom(8, 10, 0.25) + dbinom(9, 10, 0.25) + dbinom(10, 10, 0.25)
## [1] 0.000415802

You could use either

pbinom(7, 10, 0.25) - pbinom(4, 10, 0.25)
## [1] 0.07771111

or

dbinom(5, 10, 0.25) + dbinom(6, 10, 0.25) + dbinom(7, 10, 0.25)
## [1] 0.07771111

3.5.1

It is highly unlikely (but not impossible) that they are telling the truth. Using our results from 3.5, the probability of making more than 6 correct guesses out of 10 is 0.0035057, which is extremely small. This probability is almost equal to the probability of making between 7 to 8 correct guesses. To achieve this twice is highly unlikely. In conclusion the student is probably lying.

4 Overlaying a density curve on a Histogram to assess normality

4.1

4.2

This is somewhat open to interpretation. One could say that the happiness histogram looks roughly normally distributed, as the histogram itself looks roughly bell shaped, as does the density curve. The income histogram appears skewed to the right (positively skewed) and is clearly not normally distributed.


That’s everything for now! If there were any parts you were unsure about, take a look back over the relevant sections of the Topic 3 material.


References


These notes have been prepared by Amanda Shaker and Rupert Kuveke. The copyright for the material in these notes resides with the authors named above, with the Department of Mathematical and Physical Sciences and with La Trobe University. Copyright in this work is vested in La Trobe University including all La Trobe University branding and naming. Unless otherwise stated, material within this work is licensed under a Creative Commons Attribution-Non Commercial-Non Derivatives License BY-NC-ND.