Assignment 1

Due Fri 29 March 2013

Instructions

1. Cut-and-paste this document into word (or equivalent)

2. Show working where possible (eg cut-and-paste commands from an R ses- sion). 3. Submit your assignments on AUTonline

4. Remember that you can use the help system in R to provide hints.

5. Remember that you can try out ideas using the R system to check your thinking

Questions

1. (a) how many ways are there to choose 7 objects from 13? (5 marks)

> choose(13,7)

[1] 1716

> factorial(13)/(factorial(6)*factorial(7))

[1] 1716

(b) how many ways are there to arrange 12 objects? (5 marks)

> factorial(12)

[1] 479001600

> 1*2*3*4*5*6*7*8*9*10*11*12

[1] 479001600

(c) If a classroom has 25 children in it, how many ways are there to choose four children? (5 marks)

> choose(25,4)

[1] 12650

> factorial(25)/(factorial(21)*factorial(4))

[1] 12650

(d) If you have 30 children, then how many ways are there to put them into three classes of 10 each? (hint: Figure out how many ways are there to choose 10 children for the first class; and then multiply this by the number of ways of choosing 10 children for the second class) (10 marks)

> choose(30,10)*choose(20,10)

[1] 5.550997e+12

> (factorial(30)/(factorial(20)*factorial(10)))*(factorial(20)/(factorial(10)*factorial(10)))

[1] 5.550997e+12 (e) [harder] A manufacturer of widgets makes 10 widgets. Four com- panies wish to buy widgets; company A wishes to buy 4 widgets, company B wishes to buy 3 widgets, C buys 2 and company D buys one widget. How many ways can the manufacturer distribute the

10 widgets amongst the customers so each one recieves the correct number of widgets? (10 marks)

> choose(10,4)*choose(6,3)*choose(3,2)

[1] 12600

> (factorial(10)/(factorial(6)*factorial(4)))*(factorial(6)/(factorial(3)*factorial(3)))*(factorial(3)/(factorial(1)*factorial(2)))

[1] 12600

2. Here are some numbers: x mean(x)

[1] 10

> sum(x)/length(x)

[1] 10

(b) what is their mode? (5 marks)

> table(x) x 9 10 15 5 1 1

9 is their mode.

9 occur more often than any other number (five times).

(c) what is their median? (5 marks)

> median(x)

[1] 9

> sort(x)

[1] 9 9 9 9 9 10 15

> sort(x)[4]

[1] 9

(d) state why the mode is a poor representative value for this dataset

(10 marks)

9 is away from central tendency.

9 is at the extreme of the dataset.

(e) suppose, instead, that the numbers were x mean(x)

[1] 142857142865

> sum(x)/length(x)

[1] 142857142865

> median(x)

[1] 9

> sort(x)

[1] 9e+00 9e+00 9e+00 9e+00 9e+00 1e+01 1e+12

> sort(x)[4]

[1] 9

> table(x) x 9 10 1e+12 5 1 1

9 is mode.

Reason: because 1e12 is the highest number.

Mean is much larger because the mean is sensitive to the outlier of 1e12.

3. Suppose X is drawn from a standard normal distribution, mean 0 and standard deviation 1.

(a) What is the probability of X being less than 1.8? Give an R expres- sion and a numerical value to 7 signicant figures. (10 marks)

> pnorm(1.8)

[1] 0.9640697

> table(rnorm(1e6)1.9) to give and why? (5 marks)

Expect about 1e6*pnorm(1.9)[ie

Reason: We should expect about 971283 to be true. table(rnorm(1e6)>1.9) is close enough to our expectation.

> pnorm(1.9)

[1] 0.9712834

> 0.9712834*1e6

[1] 971283.4

> table(rnorm(1e6) dbinom(5,15,0.35)

[1] 0.2123387

> choose(15,5)*0.35^5*0.65^10

[1] 0.2123387

> table(rbinom(1e6,15,0.35)==5) FALSE TRUE

787498 212502

(c) What is the probability that the experiment succeeds more than 7 times? [that is, what is the probability that `r' is greater than or equal to 7?] Give a numerical value. (5 marks)

> 1-pbinom(7,15,0.35)

[1] 0.1132311

> sum(dbinom(8:15,15,0.35))

[1] 0.1132311

> table(rbinom(1e6,15,0.35)>=7) FALSE TRUE

754766 245234

(d) [harder] Use the Gaussian approximation to estimate the probability using pnorm() (5 marks)

> pnorm(7,5.25, 1.847295)

[1] 0.828265

In binomial distribution, (n=15,p=0.35,r=7)…