mathematics for statistics exercises - lancaster · numbers & data - exercises 3 1 numbers...

47
CFAS404 Mathematics for Statistics Exercise book David Lucy Department of Mathematics & Statistics Lancaster University Lancaster UK. Started on the 18 th March 2010 Latest version compiled October 1, 2014 Acknowledgements The author should like to acknowledge the contribution of Dr. Stuart Sharples of the Department of Mathematics & Statistics, Lancaster University, for his help in the revised versions of these notes. Preface These exercises are to complement the notes for CFAS404 Mathematics for Statistics. Like the notes they are fully navigable using the links. Solutions are linked to questions, and the questions to the solutions. Some of the exercises will need to be conducted using R.

Upload: vudien

Post on 30-Aug-2018

238 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Mathematics for statistics exercises - Lancaster · Numbers & data - exercises 3 1 Numbers & data - exercises 1. Odontoblasts are tooth forming cells of the mamallian body. In an

CFAS404 Mathematics for Statistics

Exercise book

David Lucy

Department of Mathematics & Statistics

Lancaster University

Lancaster

UK.

Started on the 18th March 2010

Latest version compiled October 1, 2014

Acknowledgements

The author should like to acknowledge the contribution of Dr. Stuart Sharples of the

Department of Mathematics & Statistics, Lancaster University, for his help in the

revised versions of these notes.

Preface

These exercises are to complement the notes for CFAS404 Mathematics for Statistics.

Like the notes they are fully navigable using the links. Solutions are linked to questions,

and the questions to the solutions. Some of the exercises will need to be conducted using

R.

Page 2: Mathematics for statistics exercises - Lancaster · Numbers & data - exercises 3 1 Numbers & data - exercises 1. Odontoblasts are tooth forming cells of the mamallian body. In an

CONTENTS 2

Contents

1 Numbers & data - exercises 3

2 Exponential & scientific notation - exercises 6

3 Functions - exercises 7

4 Algebra - exercises 9

5 Combinations & permutations - exercises 11

6 Differentiation - exercises 12

7 Integration - exercises 13

8 Matricies - exercises 14

9 Solutions to exercises 16

9.1 Solutions to Section 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

9.2 Solutions to Section 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

9.3 Solutions to Section 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

9.4 Solutions to Section 4 . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

9.5 Solutions to Section 5 . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

9.6 Solutions to Section 6 . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

9.7 Solutions to Section 7 . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

9.8 Solutions to Section 8 . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

Return to contents

Page 3: Mathematics for statistics exercises - Lancaster · Numbers & data - exercises 3 1 Numbers & data - exercises 1. Odontoblasts are tooth forming cells of the mamallian body. In an

Numbers & data - exercises 3

1 Numbers & data - exercises

1. Odontoblasts are tooth forming cells of the mamallian body. In an experiment to

examine the effect of vitamin C dosage and delivery method on tooth formation.

These data have the final length of odontoblasts in the teeth in each of 10 guinea

pigs at each of three dose levels of Vitamin C (0.5, 1, and 2 mg) with each of two

delivery methods: orange juice or ascorbic acid.

subject len method dose

1 4.2 VC 0.5

2 11.5 VC 1.0

3 7.3 OJ 0.5

4 5.8 VC 0.5

5 6.4 OJ 2.0

6 10.0 VC 0.5...

......

...

Answer the following:

(a) What sort of variable is the “subject” variable?

(b) How many levels does the subject variable have?

(c) What sort of variable is the “len” variable?

(d) What restrictions might apply to the len variable?

(e) What sort of variable is the “supp” variable?

(f) What sort of variable is the “dose” variable?

(g) Which variable is considered to be the response, and which are the explanatory

variables?

Solution

2. The following data are in short format. Using paper and pen rearrange them to long

format data:

table cells are weights (g)

time

chick diet 0 2 4 6 8 10 12 14 16 18 20 21

1 1 42 51 59 64 76 93 106 125 149 171 199 205

2 1 40 49 58 72 84 103 122 138 162 187 209 215

Answer the following:

(a) What sort of variable is the “chick” variable?

Return to contents

Page 4: Mathematics for statistics exercises - Lancaster · Numbers & data - exercises 3 1 Numbers & data - exercises 1. Odontoblasts are tooth forming cells of the mamallian body. In an

Numbers & data - exercises 4

(b) How many levels does the “time” variable have?

(c) What sort of variable is the “weight” variable?

(d) What restrictions might apply to the “weight” variable?

(e) Arrange the variables into a system of response and explanatory variables?

Solution

3. The following data are in long format. Using paper and pen rearrange them to short

format data:

time height age seed

1 4.51 3 301

2 10.89 5 301

3 28.72 10 301

4 41.74 15 301

5 52.70 20 301

6 60.92 25 301

1 4.55 3 303

2 10.92 5 303

3 29.07 10 303

4 42.83 15 303

5 53.88 20 303

6 63.39 25 303

Answer the following:� What sort of variable is height?� What sort of variable is seed?� What sort of variable is age?� Arrange the variables into a system of response and explanatory variables?Solution

4. Let X be the following coorrelation matrix for six tests conducted on 112 Scottish

school pupils:

general picture blocks maze reading vocab

general 1.00 0.47 0.55 0.34 0.58 0.51

picture 0.47 1.00 0.57 0.19 0.26 0.24

blocks 0.55 0.57 1.00 0.45 0.35 0.36

maze 0.34 0.19 0.45 1.00 0.18 0.22

reading 0.58 0.26 0.35 0.18 1.00 0.79

vocab 0.51 0.24 0.36 0.22 0.79 1.00

Return to contents

Page 5: Mathematics for statistics exercises - Lancaster · Numbers & data - exercises 3 1 Numbers & data - exercises 1. Odontoblasts are tooth forming cells of the mamallian body. In an

Numbers & data - exercises 5

Answer the following:

(a) What is the value of X1,2?

(b) What is the value of X4,4?

(c) What is the value of X6,1?

(d) What is the value of X1,6?

(e) What is the value of X4,2?

(f) What is the value of X3,1?

Solution

Return to contents

Page 6: Mathematics for statistics exercises - Lancaster · Numbers & data - exercises 3 1 Numbers & data - exercises 1. Odontoblasts are tooth forming cells of the mamallian body. In an

Exponential & scientific notation - exercises 6

2 Exponential & scientific notation - exercises

1. What is x multiplied by x multiplied by x multiplied by x? Solution

2. What is the product of x times x and x times x? Solution

3. What is 42 × 48? Solution

4. In log3 9 = 2 what is the logarithm? Solution

5. In log4 16 = 2 where is the base? Solution

6. In ln x = 2 which is the base? Solution

7. Express 34 = 81 as a log Solution

8. Express 25 = 52 as a log Solution

9. Express in index form log 1000 = 3 Solution

10. Express in index form ln 30 ≈ 3.401197 Solution

11. Evaluate log 100? Solution

12. Evaluate log4 64? Solution

13. If log5 125 = 3 what is ln 125 in terms of ln 5? Solution

14. Write some R code to calculate a value for e∗ Solution

∗Leave this question until the lab session when we use R

Return to contents

Page 7: Mathematics for statistics exercises - Lancaster · Numbers & data - exercises 3 1 Numbers & data - exercises 1. Odontoblasts are tooth forming cells of the mamallian body. In an

Functions - exercises 7

3 Functions - exercises

1. Let f (x) = − ln(3− x)2: evaluate:

(a) f (1)?

(b) f (3)?

(c) f (−2)?(d) f (e)?

(e) f (π)? Solution

2. Roughly sketch by hand the function y = x2 + 5x? Solution

3. Adapt the following sequence of R� generate a sequence of points:¿ x ¡- seq(from=-5, to=5, length=101)� Then generate the corresponding response values:¿ y ¡- x∧2 - 3*x + 6� finally plot the values:¿ plot(x, y)

to plot the function y = x3−5x2−15x . Experiment with R to pick a suitable rangeof values for the plot.

Solution

4. Adapt the following line of R

¿ curve(x∧2 - 3*x + 6, from=-5, to=5)

to plot the function y = x3 − 5 ∗ x2 − 15 ∗ x . Experiment with R to pick a suitablerange of values for the plot. Solution

5. In a similar way to the solution to Question 3, use R to plot the function y =

exp−(3− x)2; x ∈ {0, . . . , 6}, Solution

6. What does the curve from Question 5 remind you of? Solution

7. In a similar way to the solution to Question 4 use the curve() function in R to draw a

standard normal probability density function (µ = 0, σ2 = 1) with x ∈ {−3, . . . , 3}?Solution

8. Use the points() function to add to the figure created in Question 7 a similar

normal probability density function with parameters µ = 1, σ2 = 1.5? Solution

Return to contents

Page 8: Mathematics for statistics exercises - Lancaster · Numbers & data - exercises 3 1 Numbers & data - exercises 1. Odontoblasts are tooth forming cells of the mamallian body. In an

Functions - exercises 8

9. The β probability density function is often used in Bayesian inference to estimate the

posterior probability density function for a probability, or proportion. Its probability

density function is:

Pr(x |α, β) = f (x ;α, β) = γ(α+ β)γ(α)γ(β)

xα−1(1− x)β−1

Isolate the bit of the density function which makes a difference to the shape?

Solution

10. Use the curve() function to plot the function xα−1(1 − x)β−1; x ∈ {0, . . . , 1}where α = 2 and β = 3

Solution

11. Add to the figure created in Question 10 a similar β probability density function

with α = 3 and β = 2

Solution

12. Use the curve() function to plot the function xα−1(1− x)β−1; x ∈ {−10, . . . , 10}where α = 2 and β = 3? Solution

Return to contents

Page 9: Mathematics for statistics exercises - Lancaster · Numbers & data - exercises 3 1 Numbers & data - exercises 1. Odontoblasts are tooth forming cells of the mamallian body. In an

Algebra - exercises 9

4 Algebra - exercises

1. Expand 5(x − 2) Solution

2. Expand 2(x2 + 3x − 4) Solution

3. Expand (x + 1)(x − 1) Solution

4. Expand (2x − 3)(x + 2) Solution

5. Expand (x1 − µ)2 Solution

6. Expand 3(x − 2)(2x + 3) Solution

7. Factorize 10x2 + 5 Solution

8. Factorize 12x2 + 6x − 3 Solution

9. Factorize 8x2 − 4x Solution

10. Factorize x2 + 5x + 6 Solution

11. Factorize x2 − 3x − 10 Solution

12. Solve x2 + 8x + 15 = 0 for x Solution

13. Solve x2 + 9x = −8 for x Solution

14. Complete the square to solve x2 − 4x − 5 = 0 for x Solution

15. Complete the square to solve x2 + 8x + 13 = 0 for x Solution

16. Use the quadratic formula to solve x2 − 4x + 5 = 0 for x Solution

17. Use the quadratic formula and R to solve 7x2 + 3x = 8 for x † Solution

18. Factorize x2 − 4 Solution

19. x = {2, 4, 6, 8, 10}, evaluate x3 Solution

20. x = {2, 4, 6, 8, 10}, evaluate x4/x2 Solution

21. Write out

i=5∑

i=2

i Solution

22. Write out and evaluate

i=4∑

i=1

i2 Solution

†Leave this question until the lab session when we use R

Return to contents

Page 10: Mathematics for statistics exercises - Lancaster · Numbers & data - exercises 3 1 Numbers & data - exercises 1. Odontoblasts are tooth forming cells of the mamallian body. In an

Algebra - exercises 10

23. Write out and evaluate

i=3∑

i=0

2i Solution

24. Express in sigma notation x + 2x + 3x + . . .+ nx Solution

25. Simplify

n∑

i=1

µ− xi Solution

Return to contents

Page 11: Mathematics for statistics exercises - Lancaster · Numbers & data - exercises 3 1 Numbers & data - exercises 1. Odontoblasts are tooth forming cells of the mamallian body. In an

Combinations & permutations - exercises 11

5 Combinations & permutations - exercises

1. Evaluate 8!/2!? Solution

2. Evaluate 30789!/30787? Solution

3. How many distinct hands of 5 cards are possible from the red cards in a pack?

Solution

4. How many arrangements of the letters of the word “BEGIN” are there which start

with a vowel? Solution

5. How many even numbers greater than 2000 can be made from the integers {1, 2, 3, 4}?Each integer may only be used once. Solution

6. A cricket captain has to pick a team of eleven members from a squad of fifteen

players, including the captain. The captain has to play. How many distinct teams

would it be possible to field? Solution

7. The cricket captain is an all rounder, but has to pick a team of four bowlers, and

six batsmen and other special positions. The squad of fifteen, including the captain,

has five bowlers, and 9 batsmen and other special positions. How many distinct

teams may the captain choose? Solution

8. Write in factorial form 5× 4× 3? Solution

9. Write in factorial form (n + 1)n(n − 1)? Solution

10. How many permutations of the letters of the word “MATHEMATICS” are there?

Solution

11. Use R to enumerate the permutations of subsets of two items from a total of five

items?‡ Solution

12. Use R to enumerate the combinations of subsets of two letters from the word

“eight”? Solution

‡Leave this question until the lab session when we use R

Return to contents

Page 12: Mathematics for statistics exercises - Lancaster · Numbers & data - exercises 3 1 Numbers & data - exercises 1. Odontoblasts are tooth forming cells of the mamallian body. In an

Differentiation - exercises 12

6 Differentiation - exercises

1. What is the derivative of f (x) = x5 with respect to x? Solution

2. What is the gradient of f (x) = x3 + 2x + 5 at x = 2? Solution

3. Find the derivative of 5√x? Solution

4. Differentiate1

x4? Solution

5. Differentiate1

3x3? Solution

6. Find the point at which the function y = −(x − 5)2 is at its maximum? Solution

7. Use R to draw the graph of, and find the derivative of y = 5x3?§ Solution

8. The kernel of a normal probability density function is the function exp [−(x − µ)2].Use R to assist you in proving the modal value occurs at x = µ Solution

§Leave this question until the lab session when we use R, and use Appendix C in the notes to assist you

Return to contents

Page 13: Mathematics for statistics exercises - Lancaster · Numbers & data - exercises 3 1 Numbers & data - exercises 1. Odontoblasts are tooth forming cells of the mamallian body. In an

Integration - exercises 13

7 Integration - exercises

1. Let f (x) = 2x2 − 1x2+ x :

(a) Roughly sketch f (x).

(b) What is the indefinite integral of f (x)?

(c) Thus evaluate∫ 4

2f (x)?

Solution

2. Let f (x) = x3 − 1x2+√x :

(a) Roughly sketch f (x).

(b) From the sketch, what is the area under the curve between x = 2 and x = 4?

(c) What is the indefinite integral of f (x)?

(d) Thus evaluate∫ 4

2f (x). Is the definite integral credible?

Solution

3. Let f (x) = x2(x − 3):

(a) Roughly sketch f (x);

(b) Having done so use the sketch to estimate the roots of f (x)?

(c) Find the roots of f (x) by factorization?

(d) use the R function polyroot() to find the positive value for x for which y = 0?¶

(e) Find, by rule, the indefinite integral of f (x),

(f) For which domain of x could f (x) be employed as a continuous probability

density function?

(g) Calculate a suitable normalizing constant if f (x) is used as a PDF?

(h) If f (x) is used as a probability density function then what is the probability of

making an observation in x which is greater then 2?

Solution

4. Let f (x) = −x3 + 5x :

(a) find, by rule, the indefinite integral of f (x),

(b) use the R function polyroot() to find the positive value for x for which y = 0,

(c) use that value for x to calculate the scaling constant for the use of f (x) as a

probability density function.

(d) Consider f (x) as a probability density function, find the modal value of f (x).

(e) What is Pr(1 ≤ X ≤ 2)?

Solution

¶Only do this if you are in a lab session with access to R.

Return to contents

Page 14: Mathematics for statistics exercises - Lancaster · Numbers & data - exercises 3 1 Numbers & data - exercises 1. Odontoblasts are tooth forming cells of the mamallian body. In an

Matricies - exercises 14

8 Matricies - exercises

1. Calculate:

2, 7

4, 3

1, 6

+

4, 2

1, 4

3, 2

Solution

2. Calculate:(

−1, 6, 42,−3,−1

)

+

(

−2,−2, 31, 4, 3

)

Solution

3. Let:

A

(

1, 3, 2

3, 4, 1

)

and B =

2, 1

4, 3

3, 2

(a) What is the dimension of AB?

(b) Calculate AB?

(c) What is the dimension of BA?

(d) Calculate BA?

Solution

4. Let:

A

2, 3

1, 4

2, 3

and B =

(

4, 2

3, 1

)

(a) What is the dimension of AB?

(b) Calculate AB?

(c) What is the dimension of BA?

(d) Calculate BA?

Solution

5. Let:

A =

(

3, 4

2, 5

)

(a) What is AI2?

(b) What is I2A?

(c) What is |A|?(d) Calculate A−1

Return to contents

Page 15: Mathematics for statistics exercises - Lancaster · Numbers & data - exercises 3 1 Numbers & data - exercises 1. Odontoblasts are tooth forming cells of the mamallian body. In an

Matricies - exercises 15

(e) Calculate A−1A

Solution

6. Let:

A =

(

2, 4

3, 6

)

(a) What is |A|?(b) Calculate A−1?

Solution

7. Solve the following system of equations for x and y :

3x + 5y + 2 = 0

−6y + 4x − 7 = 2

Solution

8. Use R with the matrix() function‖, and c() operation, to construct the matrix:

a =

2, 5, 3

4, 1, 4

3, 6, 2

(a) Use the R function det to find |a|?(b) Use the R function solve to find a−1?

(c) Use the R matrix multiplication operator (%*%) and the round() function to

check that a−1a = I3?

Solution

‖You may wish to look at the help page for matrix(), use help.start() to get R’s help system going.

Return to contents

Page 16: Mathematics for statistics exercises - Lancaster · Numbers & data - exercises 3 1 Numbers & data - exercises 1. Odontoblasts are tooth forming cells of the mamallian body. In an

Solutions to exercises 16

9 Solutions to exercises

Return to contents

Page 17: Mathematics for statistics exercises - Lancaster · Numbers & data - exercises 3 1 Numbers & data - exercises 1. Odontoblasts are tooth forming cells of the mamallian body. In an

9.1 Solutions to Section 1 17

9.1 Solutions to Section 1

1. (a) The “subject” variable is a number indicating the guinea pig number, so it is

a factor, and the ordering of the levels has no meaning.

(b) It has ten levels.

(c) The “len” variable is a continuous variable.

(d) You cannot have a negative length, so it must be greater than zero.

(e) The “supp” variable indicates whether the dose was given as ascorbic acid of

orange juice, so is a factor.

(f) The “dose” variable is interesting. It’s underlying form is as a continuous

variable, that is doses can take on any value greater than zero, however, here

it is being controlled. So here it is being used as an ordered categorical variable,

but its true nature is as a continuous variable so it could be treated as either.

(g) In this experiment the dose was being controlled, as was the means by which

the dose was administered. The only variable free to vary was the length, so

that is a response to the controlled changes in dose and method, so those two

are the explanatory variables.

Return to question

2. The long format data should look like:

Return to contents

Page 18: Mathematics for statistics exercises - Lancaster · Numbers & data - exercises 3 1 Numbers & data - exercises 1. Odontoblasts are tooth forming cells of the mamallian body. In an

9.1 Solutions to Section 1 18

observation weight(g) time chick diet

1 42 0 1 1

2 51 2 1 1

3 59 4 1 1

4 64 6 1 1

5 76 8 1 1

6 93 10 1 1

7 106 12 1 1

8 125 14 1 1

9 149 16 1 1

10 171 18 1 1

11 199 20 1 1

12 205 21 1 1

13 40 0 2 1

14 49 2 2 1

15 58 4 2 1

16 72 6 2 1

17 84 8 2 1

18 103 10 2 1

19 122 12 2 1

20 138 14 2 1

21 162 16 2 1

22 187 18 2 1

23 209 20 2 1

24 215 21 2 1

(a) The “chick” variable is a factor.

(b) The “time” variable has 12 ordered levels.

(c) The “weight” variable is continuous.

(d) The “weight” variable can take on no value less than zero.

(e) Weight must depend upon time, diet, and with some individual variation due

to the chick, so weight is response, and the rest explanatory.

Return to question

3. The short format arrangement should look like:

seed 3 5 10 15 20 25

301 4.51 10.89 28.72 41.74 52.70 60.92

302 4.55 10.92 29.07 42.83 53.88 63.39

(a) The height variable is continuous. As negative heights are impossible then it

is bounded at zero.

Return to contents

Page 19: Mathematics for statistics exercises - Lancaster · Numbers & data - exercises 3 1 Numbers & data - exercises 1. Odontoblasts are tooth forming cells of the mamallian body. In an

9.1 Solutions to Section 1 19

(b) The seed variable is an indicator referring to the individual seed, so is a factor.

(c) The underlying type of variable for age is continuous, however here it has been

discreetised into six ordered categories.

(d) As age and seed cannot be effected by height, it must be that height is a

response to the explanatory variables of age and seed.

Return to question

4. The values are:

(a) X1,2 = 0.47

(b) X4,4 = 1.00

(c) X6,1 = 0.51

(d) X1,6 = 0.51

(e) X4,2 = 0.19

(f) X3,1 = 0.55

Return to question

Return to contents

Page 20: Mathematics for statistics exercises - Lancaster · Numbers & data - exercises 3 1 Numbers & data - exercises 1. Odontoblasts are tooth forming cells of the mamallian body. In an

9.2 Solutions to Section 2 20

9.2 Solutions to Section 2

1. x4 Return to question

2. x × x = x2x2 × x2 = x4 Return to question

3. 44 × 48 = 412 Return to question

4. 2 Return to question

5. 4 Return to question

6. The base is e and unstated. Return to question

7. log3 81 = 4 Return to question

8. log5 25 = 2 Return to question

9. 103 = 1000 Return to question

10. e3.401197 = 30 Return to question

11. 2 Return to question

12. 3 Return to question

13. log5 125 = 3

53 = 125

3 ln 5 = ln 125 Return to question

14. We know that e = limn→∞(1+1/n)n. So we can simply write some R code to calculate

for an instance of n, then re-run it whilst increasing n, so:

¿ n ¡- 5

¿ (1 + 1/n)∧n

[1] 2.48832

¿ n ¡- 200

¿ (1 + 1/n)∧n

1] 2.711517

Use the up key to avoid typing in (1+1/n)n repeatedly. When you get to n ≈ 2×108the value of e = 2.718282 Return to question

Return to contents

Page 21: Mathematics for statistics exercises - Lancaster · Numbers & data - exercises 3 1 Numbers & data - exercises 1. Odontoblasts are tooth forming cells of the mamallian body. In an

9.3 Solutions to Section 3 21

9.3 Solutions to Section 3

1. (a) f (1) ≈ 0.018(b) f (3) = 1

(c) f (−2) ≈ 1.38 × 10−11

(d) f (e) ≈ 0.924(e) f (π) ≈ 0.980 Return to question

2. A suitable range are the integers from −3 to 4. We shall not give the sketch here,but the values are:

x −x2 5x −x2 + 5x−3 −9 −15 −24−2 −4 −10 −14−1 −1 −5 −60 0 0 0

1 −1 5 4

2 −4 10 6

3 −9 15 6

4 −16 20 6

Return to question

3. A suitable range is x ∈ {−5, . . . 10}. The first thing is to generate a sequence ofvalues and check them:

¿ x ¡- seq(from=-5, to=10, length=101)

¿ x

[1] -5.00 -4.85 -4.70 -4.55 -4.40 -4.25 -4.10 -3.95 -3.80 -3.65

...

[97] 9.40 9.55 9.70 9.85 10.00 ∗∗

Then construct the y values from the x values, then check those:

¿ y ¡- x∧3 - 5*x∧2 - 15*x

¿ y

[1] -175.000000 -158.946625 -143.773000 -129.458875

...

[97] 247.784000 271.721375 296.723000 322.809125 ††

The plot up the two sets of values:

plot(x, y, xlab=”x”, ylab=”x∧3 - 5*x∧2 - 15*x”)

∗∗These are not an accurate representation of all the values in x . They had to be truncated to make

them fit on the page.††Ditto here about the truncation.

Return to contents

Page 22: Mathematics for statistics exercises - Lancaster · Numbers & data - exercises 3 1 Numbers & data - exercises 1. Odontoblasts are tooth forming cells of the mamallian body. In an

9.3 Solutions to Section 3 22

x

x^3

− 5

*x^2

− 1

5*x

−5 0 5 10

−100

0

100

200

300

Return to question

4. Much much easier:

¿ curve(x∧3 - 5*x∧2 - 15*x, from=-5, to=10, xlab=”x”)

x

x^3

− 5

* x

^2 −

15

* x

−5 0 5 10

−100

0

100

200

300

Return to question

5. First we need to generate a sequence of ordinates from which to generate out y ’s:

¿ x ¡- seq(from=-0, to=6, length=101)

Then calculate values of y from these:

¿ y ¡- exp(-(3-x)∧2)

Then plot x against y :

plot(x, y, pch=3, xlab=”x”, ylab=”exp(-(3-x)∧2)”)

Return to contents

Page 23: Mathematics for statistics exercises - Lancaster · Numbers & data - exercises 3 1 Numbers & data - exercises 1. Odontoblasts are tooth forming cells of the mamallian body. In an

9.3 Solutions to Section 3 23

x

exp(

−(3

−x)

^2)

0 1 2 3 4 5 6

0.0

0.2

0.4

0.6

0.8

1.0

Return to question

6. It should remind you of the Gaussian probability distribution, or the so-called bell

curve. This is used to describe continuous observations in natural populations. For

instance adult human heights are distributed with a function of this form. There are

many around the central, or modal, point of the distribution, and fewer observations

in the tails. The frequency of observation falls off the further we get into the tails.

This is reflected some measurement such as adult human heights, where there are

few people under 4’ tall, many at around 5’6”, and few over 6’6”. The exact

function for the Gaussian probability function is:

Pr(x) = f (x) =1√2πσ2

exp

[−(x − µ)22σ2

]

where µ is the location parameter, and σ2 is the variance, or dispersion parameter.

Notice the equation with which we dealt in Question 5; that was:

f (x) = exp[

−(3− x)2]

In the normal density function the first term is simply a normalizing constant, that

is it is there simply to make sure the function will sum to one. The denominator

in the exponentiated bit is a part of the equation which makes the curve broader,

or narrower. Take away these parts of the normal density function and we are left

with something of the form exp (−x)2. Return to question

7. . First we need to define µ and σ2, so:

¿ mu ¡- 0

¿ sig ¡- 1

Then it is a case of plotting it up - the expression is a bit difficult:

¿ curve(1/sqrt(2*pi*sig∧2) * exp(-(x-mu)∧2/(2*sig∧2)), from=-3, to=3,

xlab=”x”, ylab=”N pdf”)

Return to contents

Page 24: Mathematics for statistics exercises - Lancaster · Numbers & data - exercises 3 1 Numbers & data - exercises 1. Odontoblasts are tooth forming cells of the mamallian body. In an

9.3 Solutions to Section 3 24

x

N p

df

−3 −2 −1 0 1 2 3

0.0

0.1

0.2

0.3

0.4

Return to question

8. First we need to change µ and σ2 to the new values:

¿ mu ¡- 1

¿ sig ¡- 1.5

Then use the add=TRUE argument to the curve() function - use of the up key is

recommended:

¿ curve(1/sqrt(2*pi*sig∧2) * exp(-(x-mu)∧2/(2*sig∧2)), add=TRUE, col=”red”)

x

N p

df

−3 −2 −1 0 1 2 3

0.0

0.1

0.2

0.3

0.4

Notice how changing the location and dispersion parameters has changed the shape

of the function making it broader and moved over to the right. Return to question

9. Of the β probability density function:

Pr(x |α, β) = f (x ;α, β) = γ(α+ β)γ(α)γ(β)

xα−1(1− x)β−1

Return to contents

Page 25: Mathematics for statistics exercises - Lancaster · Numbers & data - exercises 3 1 Numbers & data - exercises 1. Odontoblasts are tooth forming cells of the mamallian body. In an

9.3 Solutions to Section 3 25

The:γ(α+ β)

γ(α)γ(β)

bit is not a function of x , thus does not vary with x , so given the parameters α

and β, calculation of this constant is simply a means of normalising the equation to

make sure it sums to one. The actual working bit is:

xα−1(1− x)β−1

Return to question

10. Very similar to generating the normal probability density function. First define α

and β:

¿ alpha ¡- 2

¿ beta ¡- 3

Then plot the function:

¿ curve(x∧(alpha-1)*(1-x)∧(beta-1), from=0, to=1, xlab=”x”, ylab=”beta

pdf”)

x

beta

pdf

0.0 0.2 0.4 0.6 0.8 1.0

0.00

0.05

0.10

0.15

Return to question

11. Redefine values for α and β: ¿ alpha ¡- 3

¿ beta ¡- 2

Then plot the function:

¿ curve(x∧(alpha-1)*(1-x)∧(beta-1), add=TRUE, col=”red”)

Return to contents

Page 26: Mathematics for statistics exercises - Lancaster · Numbers & data - exercises 3 1 Numbers & data - exercises 1. Odontoblasts are tooth forming cells of the mamallian body. In an

9.3 Solutions to Section 3 26

x

beta

pdf

0.0 0.2 0.4 0.6 0.8 1.0

0.00

0.05

0.10

0.15

Notice how the shape moves with change in the parameters α and β.

Return to question

12. Exactly the same solution as for 10 except the range is changed. First define α and

β:

¿ alpha ¡- 2

¿ beta ¡- 3

Then plot the function:

¿ curve(x∧(alpha-1)*(1-x)∧(beta-1), from=-10, to=10, xlab=”x”, ylab=”beta

pdf”)

x

x^(a

lpha

− 1

) *

(1 −

x)^

(bet

a −

1)

−10 −5 0 5 10

−1000

−500

0

500

This is why to be used as a probability density function the β function has to be

constrained so the x ∈ {0, . . . , 1} as outside of this range it has distinctly non-density function sorts of properties

Return to question

Return to contents

Page 27: Mathematics for statistics exercises - Lancaster · Numbers & data - exercises 3 1 Numbers & data - exercises 1. Odontoblasts are tooth forming cells of the mamallian body. In an

9.4 Solutions to Section 4 27

9.4 Solutions to Section 4

1. 5(x − 2) = 5x − 10. Return to question

2. 2(x2 + 3x − 4) = 2x2 + 6x − 8. Return to question

3. (x + 1)(x − 1) = x2 − 1. Return to question

4. (2x − 3)(x + 2) = 2x2 + x − 6. Return to question

5. (x1 − µ)2 = (x1 − µ)(x1 − µ) = x2i − 2xiµ− µ2. Return to question

6.

3(x − 2)(2x + 3) = 3[2x2 − 4x + 3x + (−2 + 3)]= 3(2x2 − x + 1)= 6x2 − 3x + 3

Return to question

7. 10x2 + 5 = 5(2x2 + 1. Return to question

8. 12x2 + 6x − 3 = 3(4x2 + 2x − 1. Return to question

9. 8x2 − 4x = 4x(2x − 1). Return to question

10. x2 + 5x + 6: factors of 6 are 2 and 3, these also

add up to give 5, so two factors could be: (x + 2)(x + 3). Return to question

11. x2 − 3x − 10: factors of 10 are again 3 and 5, and also 5 − 3 = 2, so the factorsare (x − 5)(x + 2), you may have to play around with the coefficients to get theplus and minus the right way around. Return to question

12. x2 + 8x + 15 = 0: First factorize this into (x + 3)(x + 5) = 0 then we know that

either x + 3 = 0 so x = −3, or, x + 5 = 0, so x = −5. Return to question

13. x2 + 9x = −8: rearrange so that x2 + 8x + 8 = 0, easy to factorize into (x +1)(x + 8) = 0. So either x + 1 = 0, so x = −1, or, x + 8 = 0, and x = −8Return to question

14. Solve x2 − 4x − 5 for xx2 − 4x − 5 = 0

x2 − 4x = 5

x2 − 4x + 4 = 9 (add 42/4 = 4)

(x − 2)(x − 2) = 9 (by factorizing)

(x − 2)2 = 9

x = ±√9 + 2

= 5 or 1

Return to question

Return to contents

Page 28: Mathematics for statistics exercises - Lancaster · Numbers & data - exercises 3 1 Numbers & data - exercises 1. Odontoblasts are tooth forming cells of the mamallian body. In an

9.4 Solutions to Section 4 28

15. Solve x2 + 8x + 15 = 0 for x

x2 + 8x + 13 = 0

x2 + 8x = −13x2 + 8x + 16 = −13 + 16 (add 82/4 = 16)x2 + 8x + 16 = 3

(x + 4)(x + 4) = 3 (by factorizing)

x =√3± 4

≈ 5.73 or − 2.27

Return to question

16. Solve x2−4x −5 = 0 for x . In the quadratic formula in this instance a = 1, b = −4and c = −5.

x =−b ±

√b2 − 4ac2a

=4±√16− 4×−52

=4±√36

2

=4± 62

= 5 or − 1

which is cross checked against the answer to Question 16. Return to question

17. Solve 7x2 + 3x = 8 for x using R:

Using the quadratic formula in this case a = 7, b = 3 and c = −8 as we need theequation as being equal to zero.

So using R:

¿ a ¡- 7

¿ b ¡- 3

¿ c ¡- -8

¿ (-b + sqrt((b2̂ - 4 * a * c)))/ (2 * a)

[1] 0.8760241

Use the up key and change the line in R:

¿ (-b - sqrt((b2̂ - 4 * a * c)))/ (2 * a)

[1] -1.304596 Return to question

18. Factorize x2 − 4. This is a difference of squares, and we can factorize it into(x + 2)(x − 2) simply by inspection Return to question

Return to contents

Page 29: Mathematics for statistics exercises - Lancaster · Numbers & data - exercises 3 1 Numbers & data - exercises 1. Odontoblasts are tooth forming cells of the mamallian body. In an

9.4 Solutions to Section 4 29

19. x3 = 6. Return to question

20. x4/x2 = 8/4 = 2 . Return to question

21.

i=5∑

i=2

i = 2 + 3 + 4 + 5. Return to question

22.

i=4∑

i=1

i2 = 12 + 22 + 32 + 42

= 1 + 4 + 9 + 16

31

Return to question

23.

i=3∑

i=0

2i = 20 + 21 + 22 + 23

= 1 + 2 + 4 + 8

= 15

. Return to question

24. In sigma notation:

x + 2x + 3x + . . .+ nx = x(1 + 2 + . . .+ n)

= x

n∑

i=1

xi

Return to question

25. Simplify:

n∑

i=1

µ− xi = µ− x1 + µ− x2 + . . .+ µ− xn

= nµ− x1 +−x2 + . . .+−xn

n∑

i=1

(−xi)

Return to question

Return to contents

Page 30: Mathematics for statistics exercises - Lancaster · Numbers & data - exercises 3 1 Numbers & data - exercises 1. Odontoblasts are tooth forming cells of the mamallian body. In an

9.5 Solutions to Section 5 30

9.5 Solutions to Section 5

1. 8!/2! is:

8× 7× 6× 5× 4× 3× 2× 12× 1 = 8× 7× 6× 5× 4× 3 = 20160

Return to question

2. 30789!/30787 is:

30789 × 30788× 30787× . . . 130787 . . . 1

= 30789 × 30788 ≈ 9.479× 108

Return to question

3. The red cards in a conventional card pack comprise 26 cards. We are interested in

how many possible hands of 5 there are from these 26 cards. One presumes we are

not interested in the ordering of the cards, so this is a combinations problem, and

more specifically the numbers of ways in which 5 cards can be chosen from 26, so

(

26

5

)

=26!

5!(26− 5)! =26!

5!21!=26× 25× 24× 23× 22

120= 65780

Return to question

4. Ordering is important for words, so this is a permutation problem. The letters of

the word “BEGIN” have two vowels, so for the first letter we have a choice of 2.

Then for the second letter we can have any of the other letters not already selected.

There are 4 other letters, so within those there are 4! permutations. In total this

gives us 2× 4! = 48 possible words. Return to question

5. We need permutations of {1, 2, 3, 4} which are even, and greater than 2000. Toensure evenness the final digit must be either 2 or 4, and to ensure that the resultant

number is greater than 2000 the first digit must be either 2, 3 or 4, but because

having determined the final digit has to be either 2 or 4 for any permutation we only

have a choice of two of the digits for the first position. Having fixed the choices for

the first and final digits we find that we have the choice of two for the second, the

third being entirely fixed given the other digits. The table below summarizes:

digit 1st 2nd 3rd 4th

possibilities 2 2 1 2

This leaves 2× 2× 1× 2 = 8 possible numbers. Return to question

6. The cricket team comprises eleven players from a possible fifteen players. The

captain must play. This is a combination problem as the ordering of the team is

unimportant. As the captain has to play then this takes the choices down to ten

players in the team, from a squad of fourteen players, so we want:

Return to contents

Page 31: Mathematics for statistics exercises - Lancaster · Numbers & data - exercises 3 1 Numbers & data - exercises 1. Odontoblasts are tooth forming cells of the mamallian body. In an

9.5 Solutions to Section 5 31

(

14

10

)

=14!

11!(14− 11)! =14!

11!3!=14× 13× 123× 2 =

2184

6= 364

Return to question

7. The captain must play, but has to choose four bowlers from a possible five, and six

others from a possible nine. This is a combination problem with two parts. One

can think about it as a set of potential teams of bowlers for which there are:

(

5

4

)

=5!

4!(5− 4)! = 5

possibilities, and for each of those there are:

(

9

6

)

=9!

6!(9− 6)! =9!

6!3! =

9× 8× 73× 2 = 84

possible teams. The total is 5× 84 = 420 possible teams. Return to question

8. 5× 4× 3 = 5!/2!. Return to question

9.

(n + 1)n(n − 1) = (n + 1)!(n − 2)!

Return to question

10. In the letters of the word “MATHEMATICS” there are eleven letters, however there

are two “M”s, two “A”s and two “T”s, so there are:

11!

2!2!2!=11!

(2!)3=11!

23=11!

8= 4989600 ≈ 4.9896 × 106

Return to question

11. For R the (gtools) library has the permutations() and combinations() functions,

so:

¿ library(gtools)

¿ permutations(5, 2)

[,1] [,2]

[1,] 1 2

[2,] 1 3

[3,] 1 4

[4,] 1 5

[5,] 2 1...

......

Return to question

Return to contents

Page 32: Mathematics for statistics exercises - Lancaster · Numbers & data - exercises 3 1 Numbers & data - exercises 1. Odontoblasts are tooth forming cells of the mamallian body. In an

9.5 Solutions to Section 5 32

12. Again the library gtools is needed if not already loaded:

¿ library(gtools)

¿ combinations(5, 2, v=c(”e”, ”i”, ”g”, ”h”, ”t”))

[,1] [,2]

[1,] ”e” ”g”

[2,] ”e” ”h”

[3,] ”e” ”i”

[4,] ”e” ”t”

[5,] ”g” ”h”

[6,] ”g” ”i”

[7,] ”g” ”t”

[8,] ”h” ”i”

[9,] ”h” ”t”

[10,] ”i” ”t”

Return to question

Return to contents

Page 33: Mathematics for statistics exercises - Lancaster · Numbers & data - exercises 3 1 Numbers & data - exercises 1. Odontoblasts are tooth forming cells of the mamallian body. In an

9.6 Solutions to Section 6 33

9.6 Solutions to Section 6

1.d

dx(x5) = 5x4

Return to question

2. The gradient of f (x) = x3 + 2x + 5 at x = 2.

d

dx(x3 + 2x + 5) = 3x2 + 2

Substituting in x = 0 into f ′(x) we get 3×22+2 = 3×4+2 = 14. So the gradientis 14.

Return to question

3.

5√x = x

15

d

dx(x

15 ) =

1

5x−

45

=1

5x45

(1)

Return to question

4.

1

x4= x−4

d

dx(x−4) = −4× (x−4−1)

= −4× (x−5)

= − 4x5

Return to question

5. Differentiate1

3x3. Here it is important to remember that:

d

dx(axn) = a

d

dx(xn)

or in cases like these, unlike where there is no coefficient to the xn term, we get

Return to contents

Page 34: Mathematics for statistics exercises - Lancaster · Numbers & data - exercises 3 1 Numbers & data - exercises 1. Odontoblasts are tooth forming cells of the mamallian body. In an

9.6 Solutions to Section 6 34

into trouble.

d

dx

(

1

3x3

)

=1

3

d

dx(x−3)

=1

3×−3x−3−1

=1

3×−3x−4

=1

3×− 3x4

= − 1x4

Return to question

6. Maximum of y = −(x − 5)2.

f (x) = −(x − 5)2

= −[

x2 − 10x + 25]

= −x2 + 10x + 25d

dxf (x) = −2x + 10

We now wish to solve for x :

− 2x + 10 = 0

−2x = −10x = 5

So the function is minimized at x = 5. Return to question

7. Draw and differentiate y = 5x3 using R. First draw it in whatever way you fancy.

Here I use curve():

¿ curve(5*x∧3, from =-1, to=1)

The graph is not reproduced here.

Then differentiate by:

¿ deriv(y ∼ 5*x∧3, ”x”)expression({

.value ¡- 5 * x∧3

.grad ¡- array(0, c(length(.value), 1L), list(NULL, c(”x”)))

.grad[, ”x”] ¡- 5 * (3 * x∧2)

attr(.value, ”gradient”) ¡- .grad

Return to contents

Page 35: Mathematics for statistics exercises - Lancaster · Numbers & data - exercises 3 1 Numbers & data - exercises 1. Odontoblasts are tooth forming cells of the mamallian body. In an

9.6 Solutions to Section 6 35

.value

})

Here the critical part is .grad[, ”x”] ¡- 5 * (3 * x∧2). Expanding the brack-

ets we get f ′(5x3) = 15x2.

Return to question

8. The normal kernel is exp [−(x − µ)2]. Use Maple to assist in proving the modalvalue is when x = µ.

The modal value is when the function is maximized. So we want the value of x

which corresponds to the maximum value of f (x) = exp [−(x − µ)2]. To do this weneed the derivative of f (x), and we can do this using Maple:

h:=exp(-(x-mu)∧2)

e−(x−µ)2

We now differentiate the function h using the Maple diff() function:

diff(h,x)

(−2x + 2µ)e−(x−µ)2

So:d

dx(exp−(x − µ)2) = (2µ− 2x) exp

[

−(x − µ)2]

To have found the modal value in this instance we know that:

(2µ− 2x) exp[

−(x − µ)2]

= 0

By inspection of the derivative this can only happen when x = µ as it is at this

value for x that the first term in the equation (2µ − 2x) is equal to zero, with theconsequence that the value of the entire equation will also equal zero. Thus the

modal value of the normal kernel function is the parameter µ. Return to question

Return to contents

Page 36: Mathematics for statistics exercises - Lancaster · Numbers & data - exercises 3 1 Numbers & data - exercises 1. Odontoblasts are tooth forming cells of the mamallian body. In an

9.7 Solutions to Section 7 36

9.7 Solutions to Section 7

1. f (x) = 2x2 − 1x2+ x :

(a) Rough sketch of f (x).

x

f(x)

−100

−50

0

50

−4 −2 0 2 4

2x2 −1

x2 + x

Which is an odd looking thing, and of no conceivable use to statisticians. It

has a vertical asymptote at x = 0.

(b) Indefinite integral of f (x). Remembering:

axndx =a

n + 1xn+1

Rewriting:

2x2 − 1x2+ x = 2x2 − x−2 + x1

The integral can be evaluated as:

f (x) dx =

2x2 dx −∫

x−2 dx +

x1 dx + C

=2

3x3 − 1−1x

−1 +1

2x2 +C

=2

3x3 +

1

2x2 +

1

x+ C

(c) Value for∫ 4

2f (x)?

Return to contents

Page 37: Mathematics for statistics exercises - Lancaster · Numbers & data - exercises 3 1 Numbers & data - exercises 1. Odontoblasts are tooth forming cells of the mamallian body. In an

9.7 Solutions to Section 7 37

∫ 4

2

f (x) =

[

2

343 +

1

242 +

1

4

]

−[

2

323 +

1

222 +

1

2

]

=

[

2

3× 64 + 1

2× 16 + 1

4

]

−[

2

3× 8 + 1

2× 4 + 1

2

]

=

[

152

3+1

4

]

−[

16

3+5

2

]

=517

12

Return to question

2. f (x) = x3 − 1x2+√x :

(a) Rough sketch of f (x).

x

f(x)

−100

−50

0

50

100

−4 −2 0 2 4

x3 −1

x2 + x

Again, another really strange looking function with no possible statistical use.

(b) From the sketch:

x

f(x)

0

20

40

60

80

100

0 1 2 3 4 5

x3 −1

x2 + x

Return to contents

Page 38: Mathematics for statistics exercises - Lancaster · Numbers & data - exercises 3 1 Numbers & data - exercises 1. Odontoblasts are tooth forming cells of the mamallian body. In an

9.7 Solutions to Section 7 38

we see that the area under the curve will be a bit less than the area of the

rectangle, plus the triangle. The rectangle has a height of about 10, and the

triangle a height of 55 above the rectangle, so the area is ≈ 2×10+ 12×2×55 =

20 + 55 = 75. So the area will be a bit less than 75.

(c) Indefinite integral:

Remembering:

axndx =a

n + 1xn+1

Rewriting:

x3 − 1x2+√x = x3 + x−2 + x0.5

Integrating a sum:

x3 + x−2 + x0.5 dx =

x3 dx +

x−2 dx +

x0.5 dx

=1

4x4 +

1

−1x−1 +

2

3x32 + C

=x4

4+2

3

√x3 − 1

x+C

(d) Value for∫ 4

2f (x)?

∫ 4

2

f (x) =

[

44

4+2

3

√43 − 1

4

]

−[

24

4+2

3

√23 − 1

2

]

=

[

256

4+2

3

√64− 1

4

]

−[

16

4+2

3

√8− 24

]

=

[

256

4+32

4− 14

]

−[

14

4+2

3

√8

]

=287

4−[

14

4+2

3

√8

]

=287

4− 144− 23

√8

=273

4− 23

√8

≈ 66.36 (2)

so yes, it is a credible value for the area.

Return to question

3. Here f (x) = −x2(x − 3):

Return to contents

Page 39: Mathematics for statistics exercises - Lancaster · Numbers & data - exercises 3 1 Numbers & data - exercises 1. Odontoblasts are tooth forming cells of the mamallian body. In an

9.7 Solutions to Section 7 39

(a) Sketch of f (x);

x

f(x)

0

1

2

3

4

5

−1 0 1 2 3 4

− x2(x−3)

(b) Use the sketch to estimate the roots of f (x)? The roots of f (x) are where

f (x) = 0. From the sketch the roots are about x = 0, and x = 3.

(c) Roots of f (x) by factorization? −x2(x − 3) can be written −(x + 0)×−(x +0) × (x − 3). f (x) evaluates to zero if any of these terms are zero, so x = 0both (x + 0) terms are zero, and when x − 3 = 0, x must equal 3. So theroots are 0 and 3.

(d) Use polyroot() to find the roots of f (x). −x2(x−3) can be written −x3+3x2.This is a cubic with coefficients -1, 3, 0, 0, for the x3, x2, x and constant terms

respectively. In R:

¿ polyroot(c(0, 0, 3, -1))

[1] 0+0i 0+0i 3+0i

Taking the real components we see polyroot() gives us the roots 0 and 3 for

f (x).

(e) Find, by rule, the indefinite integral of f (x): Remembering:

axndx =a

n + 1xn+1

Rewriting −x3 + 3x2 as 3x2 − x3 By rule we can say that:

3x2 − x3dx =∫

3x2dx +−∫

x3dx +C

=3

3x3 − 1

4x4 +C

= x3 − 14x4 + C

(f) For which domain of x could f (x) be a PDF? The roots are 0 and 3, we see

from the sketch that f (x) ≥ 0, so x ∈ {0, 3} would be a suitable domain.

Return to contents

Page 40: Mathematics for statistics exercises - Lancaster · Numbers & data - exercises 3 1 Numbers & data - exercises 1. Odontoblasts are tooth forming cells of the mamallian body. In an

9.7 Solutions to Section 7 40

(g) Normalizing constant: For f (x) ∈ {0, 3} if f (x) is a PDF, so the normalizingconstant is the reciprocal of:

∫ 3

0

f (x) = 33 − 1434 +C

= 27− 814

=108

4− 814

=27

4

So the normalizing constant is 4/27.

(h) Pr(X ≥ 2)?First calculate Pr(X ≤ 2):

Pr(X ≤ 2) =∫ 2

0

f (x)

=4

27

[

23 − 14× 24

]

=4

27

[

8− 14× 16

]

=16

27

So Pr(X ≥ 2) = 1− 1627= 1127≈ 0.40.

Return to question

4. Drawing y = −x3 + 5x we see:

x

f(x)

0

1

2

3

4

0 1 2

Return to contents

Page 41: Mathematics for statistics exercises - Lancaster · Numbers & data - exercises 3 1 Numbers & data - exercises 1. Odontoblasts are tooth forming cells of the mamallian body. In an

9.7 Solutions to Section 7 41

Which crosses the x axis at y = 0 and some other value of x as yet to be calculated.

This function, within a suitable domain for x , is therefore suited to be used as a

probability density function.

(a) Indefinite integral:

Remembering:

axndx =a

n + 1xn+1

By rule we can say that:

−x3 + 5x dx = −14x4 +

5

2x2 + C

(b) −x3 + 5x = 0 at x = 0. Using in R:¿ polyroot(c(0, 5, -1))

[1] 2.236068+0i -2.236068+0i

which gives is the positive root of f (x), so the domain for f (x) to be a prob-

ability density function is 0 ≤ X ≤ 2.236068.(c) Putting x = 2.236068 into:

−14x4 +

5

2x2 = 6.25

So the scaling factor is 1/6.25.

(d) Finding:

∫ 2

1

−x3 + 5x dx =[

−14× 24 + 5

2× 22

]

−[

−14× 14 + 5

2× 12

]

= 6− 2.5= 3.75

Rescaling this 3.75/6.25 = 0.6, or in other words Pr(1 ≤ X ≤ 2) = 0.6, or60%

Return to question

Return to contents

Page 42: Mathematics for statistics exercises - Lancaster · Numbers & data - exercises 3 1 Numbers & data - exercises 1. Odontoblasts are tooth forming cells of the mamallian body. In an

9.8 Solutions to Section 8 42

9.8 Solutions to Section 8

1.

2, 7

4, 3

1, 6

+

4, 2

1, 4

3, 2

=

6, 9

5, 7

4, 8

Return to question

2.(

−1, 6, 42,−3,−1

)

−(

−2,−2, 31, 4, 3

)

=

(

1, 8, 1

1,−7,−4

)

Return to question

3.

A =

(

1, 3, 2

3, 4, 1

)

and B =

2, 1

4, 3

3, 2

(a) What is the dimension of AB? A has two rows, and B has two columns, so

the product will have two rows and two columns.

(b) Calculate AB?

AB =

(

1, 3, 2

3, 4, 1

)

×

2, 1

4, 3

3, 2

=

[

(1× 2) + (3× 4) + (2× 3), (1× 1) + (3× 3) + (2× 2)(3× 2) + (4× 4) + (1× 3), (3× 1) + (4× 3) + (1× 2)

]

=

(

2 + 12 + 6, 1 + 9 + 4

6 + 16 + 3, 3 + 12 + 2

)

=

(

20, 14

25, 17

)

(c) What is the dimension of BA? B has three rows, and A has three columns,

so the product will have three rows and three columns.

Return to contents

Page 43: Mathematics for statistics exercises - Lancaster · Numbers & data - exercises 3 1 Numbers & data - exercises 1. Odontoblasts are tooth forming cells of the mamallian body. In an

9.8 Solutions to Section 8 43

(d) Calculate BA?

BA =

2, 1

4, 3

3, 2

×(

1, 3, 2

3, 4, 1

)

=

(2× 1) + (1× 3), (2× 3) + (1× 4), (2× 2) + (1× 1)(4× 1) + (3× 3), (4× 3) + (3× 4), (4× 2) + (3× 1)(3× 1) + (2× 3), (3× 3) + (2× 4), (3× 2) + (2× 1)

=

2 + 3, 6 + 4, 4 + 1

4 + 9, 12 + 12, 8 + 3

3 + 6, 9 + 8, 6 + 2

=

5, 10, 5

13, 24, 11

9, 17, 8

Return to question

4.

A

2, 3

1, 4

2, 3

and B =

(

4, 2

3, 1

)

(a) What is the dimension of AB? A has two columns and three rows, and B has

two columns and two rows, so the product AB will have two rows and three

columns.

(b) Calculate AB?

AB =

2, 3

1, 4

2, 3

×(

4, 2

3, 1

)

=

(2× 4) + (3× 3), (2× 2) + (3× 1)(1× 4) + (4× 3), (1× 2) + (4× 1)(2× 4) + (3× 3), (2× 2) + (3× 1)

=

8 + 9, 4 + 3

4 + 12, 2 + 4

8 + 9, 4 + 3

=

17, 7

16, 6

17, 7

(c) What is the dimension of BA? B has two columns and A has three rows, so the

two matricies are non-conformable and the product BA cannot be calculated.

(d) Calculate BA? BA are non-conformable matricies.

Return to question

Return to contents

Page 44: Mathematics for statistics exercises - Lancaster · Numbers & data - exercises 3 1 Numbers & data - exercises 1. Odontoblasts are tooth forming cells of the mamallian body. In an

9.8 Solutions to Section 8 44

5.

A =

(

3, 4

2, 5

)

(a) What is AI2?

AI2 =

(

3, 4

2, 5

)

×(

1, 0

0, 1

)

=

[

(3× 1) + (4× 0), (3× 0) + (4× 1)(2× 1) + (5× 0), (2× 0) + (5× 1)

]

=

(

3, 4

2, 5

)

(b) What is I2A?

AI2 = 5

(

1, 0

0, 1

)

×(

3, 4

2, 5

)

=

[

(1× 3) + (0× 2), (1× 4) + (0× 5)(0× 3) + (1× 2), (0× 4) + (1× 5)

]

=

(

3, 4

2, 5

)

(c) What is |A|? For a 2× 2 matrix:∣

a, b

c, d

= ad − bc

so in this case:

|A| =∣

3, 4

2, 5

= 3× 5− 2× 4 = 15− 8 = 7

(d) Calculate A−1? For a 2× 2 matrix:(

a, b

c, d

)−1

=1

ad − bc

(

d,−b−c, a

)

which here is:

A−1 =

(

3, 4

2, 5

)−1

=1

(3× 5)− (2× 4)

(

5,−4−2, 3

)

=

(

57,−4

7

−27, 37

)

Return to contents

Page 45: Mathematics for statistics exercises - Lancaster · Numbers & data - exercises 3 1 Numbers & data - exercises 1. Odontoblasts are tooth forming cells of the mamallian body. In an

9.8 Solutions to Section 8 45

(e) Calculate A−1A?

A−1A =

(

57,−4

7

−27, 37

)

×(

3, 4

2, 5

)

=

[

(57× 3) + (−4

7× 2), (5

7× 4) + (−4

7× 5)

(−27× 3) + (3

7× 2), (−2

7× 4) + (3

7× 5)

]

=

[

157+−8

7, 207+−20

7

−67+ 67,−8

7+ 157

]

=

[

77, 07

07, 77

]

=

[

1, 0

0, 1

]

Return to question

6.

A =

(

2, 4

3, 6

)

(a) What is |A|? For a 2× 2 matrix:∣

a, b

c, d

= ad − bc

which here:

2, 4

3, 6

= 2× 6− 3× 4 = 12− 12 = 0

(b) Calculate A−1? As |A| = 0 the inverse of A is undefined and cannot becalculated.

Return to question

7. Solve for x and y :

3x + 5y + 2 = 0

−6y + 4x − 7 = 2

Rearranging so the equations can be expressed as the coefficients in a matrix:

3x + 5y = −24x − 6y = 9

The system of equations can now be written:

(

x

y

)

=

(

3, 5

4,−6

)−1

×(

−29

)

Return to contents

Page 46: Mathematics for statistics exercises - Lancaster · Numbers & data - exercises 3 1 Numbers & data - exercises 1. Odontoblasts are tooth forming cells of the mamallian body. In an

9.8 Solutions to Section 8 46

First calculating the inverse:

(

3, 5

4,−6

)−1

=1

(3×−6) − (5× 4)

(

−6,−5−4, 3

)

=

(

−6−38, −5−38

−4−38, 3−38

)

=

(

319, 538

219,− 3

38

)

Multipying:

(

319, 538

219,− 3

38

)

×(

−29

)

=

[

( 319×−2) + ( 5

38× 9)

( 219×−2) + (− 3

38× 9)

]

=

(

− 619+ 4538

− 419+−27

38

)

=

(

−1238+ 4538

− 838+−27

38

)

=

(

3338

−3538

)

So x = 3338and y = −35

38.

Return to question

8. Use matrix() and c() to construct:

a =

2, 5, 3

4, 1, 4

3, 6, 2

¿ a ¡- matrix(c(2,4,3,5,1,6,3,4,2), nrow=3, byrow=F)

Checking a:

¿ a

[, 1] [, 2] [, 3]

[1, ] 2 5 3

[2, ] 4 1 4

[3, ] 3 6 2

(a) Use the R function det to find |a|?¿ det(a)

[1] 39

Return to contents

Page 47: Mathematics for statistics exercises - Lancaster · Numbers & data - exercises 3 1 Numbers & data - exercises 1. Odontoblasts are tooth forming cells of the mamallian body. In an

9.8 Solutions to Section 8 47

(b) Use the R function solve to find a−1?

¿ solve(a)

[, 1] [, 2] [, 3]

[1, ] −0.5641026 0.20512821 0.4358974

[2, ] 0.1025641 −0.12820513 0.1025641

[3, ] 0.5384615 0.07692308 −0.4615385(c) Use the R matrix multiplication operator (%*%) and the round() function to

check that a−1a = I3?

¿ solve(a) %*% a

[, 1] [, 2] [, 3]

[1, ] 1.000000e + 00 1.110223e − 16 0.000000e + 00

[2, ] −4.163336e − 17 1.000000e + 00 −2.775558e − 17[3, ] 5.551115e − 17 1.110223e − 16 1.000000e + 00

which becomes clearer if we use the round() function:

¿ round(solve(a) %*% a, 4)

[, 1] [, 2] [, 3]

[1, ] 1 0 0

[2, ] 0 1 0

[3, ] 0 0 1

which is I3.

Return to question

Return to contents