foundations of mathematics - department linguistikvasishth/pdfs/foundationsmathematics.pdf · 5.1.1...

117
Foundations of Mathematics Lecture notes for the MSc in Cognitive Systems at the University of Potsdam, Germany Compiled by Shravan Vasishth version of February 2, 2015

Upload: dangxuyen

Post on 27-Apr-2018

225 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

Foundations of MathematicsLecture notes for the MSc in Cognitive Systems at the University of Potsdam, Germany

Compiled by Shravan Vasishth

version of February 2, 2015

Page 2: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

2

Page 3: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

Contents

1 Preface 7

2 Course schedule 9

3 Pre-calculus review 113.1 Counting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113.2 Permutations and combinations . . . . . . . . . . . . . . . . . . . 12

3.2.1 Permutations . . . . . . . . . . . . . . . . . . . . . . . . 123.2.2 Combinations . . . . . . . . . . . . . . . . . . . . . . . . 123.2.3 Binomial theorem . . . . . . . . . . . . . . . . . . . . . 12

3.3 Inequalities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123.4 Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

3.4.1 Arithmetic series . . . . . . . . . . . . . . . . . . . . . . 133.4.2 Geometric series . . . . . . . . . . . . . . . . . . . . . . 133.4.3 Power series . . . . . . . . . . . . . . . . . . . . . . . . 13

3.5 Trigonometry . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143.5.1 Basic definitions . . . . . . . . . . . . . . . . . . . . . . 143.5.2 Pythagorean identity . . . . . . . . . . . . . . . . . . . . 143.5.3 Relations between trig functions . . . . . . . . . . . . . . 153.5.4 Identities expressing trig functions in terms of their com-

plements . . . . . . . . . . . . . . . . . . . . . . . . . . 153.5.5 Periodicity . . . . . . . . . . . . . . . . . . . . . . . . . 153.5.6 Law of cosines . . . . . . . . . . . . . . . . . . . . . . . 163.5.7 Law of sines . . . . . . . . . . . . . . . . . . . . . . . . 163.5.8 Odd and even functions . . . . . . . . . . . . . . . . . . . 163.5.9 Sum formulas for sine and cosine . . . . . . . . . . . . . 163.5.10 Double angle formulas for sine and cosine . . . . . . . . . 163.5.11 Less important identities . . . . . . . . . . . . . . . . . . 17

3

Page 4: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

4 CONTENTS

4 Differentiation and integration 194.1 Differentiation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

4.1.1 Deriving a rule for differentiation . . . . . . . . . . . . . 204.1.2 Derivatives of trigonometric functions, exponential, and log 204.1.3 Derivations of combinations of functions . . . . . . . . . 214.1.4 Maxima and minima . . . . . . . . . . . . . . . . . . . . 22

4.2 Integration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244.2.1 Riemann sums . . . . . . . . . . . . . . . . . . . . . . . 244.2.2 Some common integrals . . . . . . . . . . . . . . . . . . 254.2.3 The Fundamental Theorem of Calculus . . . . . . . . . . 264.2.4 The u-substitution . . . . . . . . . . . . . . . . . . . . . 264.2.5 Change of variables (Gamma functions) . . . . . . . . . . 28

5 Matrix algebra 315.1 Introductory concepts . . . . . . . . . . . . . . . . . . . . . . . . 31

5.1.1 Basic operations . . . . . . . . . . . . . . . . . . . . . . 315.1.2 Diagonal matrix and identity matrix . . . . . . . . . . . . 335.1.3 Powers of matrices . . . . . . . . . . . . . . . . . . . . . 345.1.4 Inverse of a matrix . . . . . . . . . . . . . . . . . . . . . 345.1.5 Linear independence . . . . . . . . . . . . . . . . . . . . 375.1.6 The rank of a matrix . . . . . . . . . . . . . . . . . . . . 375.1.7 More on determinants . . . . . . . . . . . . . . . . . . . 375.1.8 Singularity . . . . . . . . . . . . . . . . . . . . . . . . . 39

5.2 Solving simultaneous linear equations . . . . . . . . . . . . . . . 395.2.1 Gaussian elimination . . . . . . . . . . . . . . . . . . . . 40

5.3 Eigenvalues and eigenvectors . . . . . . . . . . . . . . . . . . . . 475.3.1 Linear dependence . . . . . . . . . . . . . . . . . . . . . 495.3.2 Diagonalization of a matrix . . . . . . . . . . . . . . . . 515.3.3 Quadratic forms . . . . . . . . . . . . . . . . . . . . . . 53

6 Multivariate calculus 556.1 Partial derivatives . . . . . . . . . . . . . . . . . . . . . . . . . . 556.2 Drawing level curves . . . . . . . . . . . . . . . . . . . . . . . . 556.3 Double integrals . . . . . . . . . . . . . . . . . . . . . . . . . . . 57

6.3.1 How to solve double integrals . . . . . . . . . . . . . . . 576.3.2 Double integrals using polar coordinates . . . . . . . . . . 586.3.3 The Jacobian in a change of variables transformation . . . 60

Page 5: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

CONTENTS 5

7 Some background in statistics, with applications of mathematical meth-ods 657.1 Discrete random variables; Expectation . . . . . . . . . . . . . . 65

7.1.1 Examples of discrete probability distributions . . . . . . . 677.2 Continuous random variables . . . . . . . . . . . . . . . . . . . . 687.3 Important classes of continuous random variables . . . . . . . . . 71

7.3.1 Uniform random variable . . . . . . . . . . . . . . . . . . 717.3.2 Normal random variable . . . . . . . . . . . . . . . . . . 727.3.3 Exponential random variables . . . . . . . . . . . . . . . 767.3.4 Weibull distribution . . . . . . . . . . . . . . . . . . . . . 777.3.5 Gamma distribution . . . . . . . . . . . . . . . . . . . . 777.3.6 Memoryless property (Poisson, Exponential, Geometric) . 817.3.7 Beta distribution . . . . . . . . . . . . . . . . . . . . . . 867.3.8 Distribution of a function of a random variable (transfor-

mations of random variables) . . . . . . . . . . . . . . . . 877.3.9 The Poisson distribution . . . . . . . . . . . . . . . . . . 897.3.10 Geometric distribution [discrete] . . . . . . . . . . . . . . 907.3.11 Normal approximation of the binomial and poisson . . . . 91

7.4 Jointly distributed random variables . . . . . . . . . . . . . . . . 917.4.1 Joint distribution functions . . . . . . . . . . . . . . . . . 917.4.2 Conditional distributions . . . . . . . . . . . . . . . . . . 977.4.3 Joint and marginal expectation . . . . . . . . . . . . . . . 997.4.4 Conditional expectation . . . . . . . . . . . . . . . . . . 1017.4.5 Multinomial coefficients and multinomial distributions . . 1037.4.6 Multivariate normal distributions . . . . . . . . . . . . . . 104

7.5 Application of differentiation: Method of maximum likelihoodestimation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105

7.6 Application of matrices: Least squares estimation . . . . . . . . . 109

Page 6: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

6 CONTENTS

Page 7: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

Chapter 1

Preface

These notes are intended to serve as lecture notes for the MSc Cognitive Systemsfoundational course Foundations of Mathematics. The notes are based on thebooks listed in the references, and on the graduate certificate course taught at theSchool of Mathematics and Statistics (SOMAS), University of Sheffield, UK.

Homework assignments are integral to the course, but these are provided onlyto students taking the course. Solutions are usually provided a week after theassignment is handed out. The homework assignments are not graded; the studentis expected to evaluate their mistakes on their own by comparing the providedsolutions with their own attempt. The assignments will however be discussed inclass, so that there is ample opportunity for discussion of any problems that comeup.

The formal examination for this course is a 20 minute oral exam that the in-structor will conduct at the end of the course.

The offical textbook for the course is [3]; please get the second edition, pub-lished in 2002. A good, additional text (if you can afford it) is [5]; if you buy thistoo, please get the fourth edition, published in 2008.

I owe a great debt of gratitude to Fionntan Roukema at SOMAS, Sheffield. Heis the best math teacher I have ever encountered, and his teaching style has beenan inspiration to me.

7

Page 8: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

8 CHAPTER 1. PREFACE

Page 9: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

Chapter 2

Course schedule

We have approximately 14 lectures in this course (this varies a bit from year toyear).

The approximate schedule is as follows:

1. Precalculus I (HW0 assigned)

2. Discussion of solutions to HW0

3. Precalculus II (HW1 assigned)

4. Solutions HW1

5. Differentiation (HW2 assigned)

6. Solutions HW2

7. Integration (HW3 assigned)

8. Solutions HW3

9. Matrix Algebra I (HW4 assigned)

10. Matrix Algebra II, minima, maxima, partial derivatives (HW 5 assigned)

11. Solutions HW4 and HW5

12. Double integrals, change of variables (HW 6)

13. Solutions HW6

14. Review, and applications in statistics and data mining (time permitting)

9

Page 10: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

10 CHAPTER 2. COURSE SCHEDULE

Page 11: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

Chapter 3

Pre-calculus review

Sources: heavily depended on [8], [10], [3] (the official textbook in the course)and various summaries on the internet on trigonometric functions.

3.1 Counting

The number of ways in which one may select an unordered sample of k subjectsfrom a population that has n distinguishable members is

• (n�1+k)![(n�1)!k!] if sampling is done with replacement,

•�n

k�= n!

[k!(n�k)!] if sampling is done without replacement.

Table 3.1: default

ordered = TRUE ordered = FALSEreplace = TRUE nk (n�1+ k)!/[(n�1)!k!]replace = FALSE n!/(n� k)!

�nk�

11

Page 12: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

12 CHAPTER 3. PRE-CALCULUS REVIEW

3.2 Permutations and combinations

3.2.1 PermutationsFor n objects, of which n1, . . . ,nr are alike, the number of different permutationsare

n!n1!n2! . . .nr!

(3.1)

3.2.2 CombinationsChoosing k distinct objects from n, when order irrelevant:

✓nk

◆=

n!(n� r)!r!

(3.2)

3.2.3 Binomial theorem

(x+ y)n =n

Ân=0

✓nk

◆xkyn�k (3.3)

3.3 InequalitiesTo solve an inequality, we need to determine the numbers x that satisfy the in-equality. This is called the solution set of the inequality.

1. If we multiply or divide an inequality by a negative number, the inequalityis reversed.

Example: �12x < 4

2. To solve a quadratic inequality, you can always solve it by completing thesquare. Another way is to factor the quadratic (works sometimes).

Example: Solve x2 �4x+3 > 0.

Example (use completing the square): Solve x2 �2x+5 0.

Page 13: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

3.4. SERIES 13

3.4 Series

3.4.1 Arithmetic seriesGeneral form:

a+(a+d)+(a+2d)+ . . . (3.4)

k-th partial sum for arithmetic series:

Sk =k

Ân=1

(a+(n�1)d) (3.5)

The sum can be found by:

Sk =k2(2a+(k�1)d) (3.6)

3.4.2 Geometric seriesGeneral form:

a+ar+ar2 . . . (3.7)

In summation notation:

Ân=1

arn�1 (3.8)

k-th partial sum:

Sk =a� (1� rk)

1� r(3.9)

S• exists just in case | r |< 1.

S• =a

1� r(3.10)

3.4.3 Power series•

Ân=0

an(x�a)n (3.11)

Page 14: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

14 CHAPTER 3. PRE-CALCULUS REVIEW

3.5 Trigonometry

3.5.1 Basic definitions

A

B

C

c

a

b

Figure 3.1: Right-angled triangle.

sinA =opphyp

=ac

(3.12)

Cosine is the complement of the sine:

cosA = sin(90�A) = sinB (3.13)

cosA =bc

(3.14)

3.5.2 Pythagorean identity

a2 +b2 = c2 (3.15)

a2

c2 +b2

c2 = 1

sin2 A+ cos2 A = 1(3.16)

Page 15: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

3.5. TRIGONOMETRY 15

3.5.3 Relations between trig functions

tanA =sinAcosA

=ac/

bc=

ab=

oppad j

(3.17)

tanA is also the slope of a line.

cotA =1

tanA=

cosAsinA

(3.18)

secA =1

cosA(3.19)

cscA =1

sinA(3.20)

sin A = a/c (opp/hyp) csc A = c/a (hyp/opp)cos A = b/c (adj/hyp) sec A = c/b (hyp/adj)tan A = a/b (opp/adj) cot A = b/a (adj/opp)

Note that cot A = tan B, and csc A = sec B.

3.5.4 Identities expressing trig functions in terms of their com-plements

cos t = sin(p/2-t) sin t = cos(p/2-t)cot t = tan(p/2-t) tan t = cot(p/2-t)csc t = sec(p/2-t) sec t = csc(p/2-t)

3.5.5 Periodicity

sin t +2p = sin t sin t +p =�sin tcos t +2p = cos t cos t +p =�cos ttan t +2p = tan t tan t +p = tan t

sin0 = 0 cos0 = 1 tan0 = 0sin p

2 = 1 cos p2 = 0 tan p

2 undefinedsinp = 0 cosp =�1 tanp =�1

Page 16: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

16 CHAPTER 3. PRE-CALCULUS REVIEW

3.5.6 Law of cosinesThree ways of writing it:

c2 = a2 +b2 �2abcosC (3.21)

a2 = b2 + c2 �2bccosC (3.22)

b2 = c2 +a2 �2cacosC (3.23)

3.5.7 Law of sinessinA

a=

sinBb

=sinC

c(3.24)

3.5.8 Odd and even functionsA function f is said to be an odd function if for any number x, f (�x) = � f (x)(e.g., f (y) = x5). A function f is said to be an even function if for any number x,f (�x) = f (x) (e.g., f (y) = x4).

Odd functions: sin, tan, cotan, csc.Even functions: cos, sec.

3.5.9 Sum formulas for sine and cosine

sin(s+ t) = sinscos t + cosssin t (3.25)

cos(s+ t) = cosscos t � sinssin t (3.26)

3.5.10 Double angle formulas for sine and cosine

sin2t = 2sin t cos t (3.27)

cos2t = cos2 t � sin2 t = 2cos2 t �1 = 1�2sin2 t (3.28)

Page 17: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

3.5. TRIGONOMETRY 17

3.5.11 Less important identitiesPythagorean formula for tan and sec:

sec2 t = 1+ tan2 t (3.29)

Identities expressing trig functions in terms of their supplements

sin(p � t) = sin t (3.30)

cos(p � t) =�cos t (3.31)

tan(p � t) =� tan t (3.32)

Difference formulas for sine and cosine

sin(s� t) = sinscos t � cosssin t (3.33)

cos(s� t) = cosscos t + sinssin t (3.34)

Page 18: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

18 CHAPTER 3. PRE-CALCULUS REVIEW

Page 19: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

Chapter 4

Differentiation and integration

4.1 DifferentiationGiven a function f (x), the derivative from first principles is as follows:

If we want to find ∂y∂x , note that ∂y = f (x+∂x)� f (x):

y = f (x)y+∂y = f (x+∂x)

(4.1)

Subtracting y from both sides:

y+∂y� y = f (x+∂x)� y∂y = f (x+∂x)� f (x)

(4.2)

It follows that ∂y∂x =

f (x+∂x)� f (x)∂x . If we write the first derivative ∂y

∂x as f (1)(x),we have the following identity:

f (1)(x) =f (x+∂x)� f (x)

∂x(4.3)

Other notations we will use interchangeably: Given y = f(x),∂y∂x =

dydx = f (1)(x) = y0.

Note:

1. The derivative of a function at some point c is the slope of the function atthat point c. The slope is the rate of growth: dy

dx .

19

Page 20: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

20 CHAPTER 4. DIFFERENTIATION AND INTEGRATION

2. The derivative f 0 is itself a function, and can be further differentiated. So,the second derivative, f 00 is the rate of change of the slope. This will soonbecome a very important fact for us when we try to find maxima and minimaof a function.

4.1.1 Deriving a rule for differentiationConsider the function y = x2. Suppose we increase x by a small amount dx, ywill also increase by some small amount dy. We can ask: what is the ratio of theincreases: dy

dx? We will derive this next:

y+dy = (x+dx)2 (4.4)

Expanding out the RHS:

y+dy = x2 +dx2 +2xdx (4.5)

Observe that squaring a small quantity dx will make it even smaller (e.g., trysquaring 1/100000000; it is effectively zero). That leads to the following simpli-fication:

y+dy = x2 +2xdx as dx gets infinitesimally small (4.6)

Subtracting y from both sides:

dy = 2xdx , dydx

= 2x (4.7)

Exercise: Find the derivative of x3,x4,x5 using the above approach. Evaluateeach derivative at c=2.

The general rule is that

dydx

= nxn�1 (4.8)

Verify that this rule works for negative powers and fractional powers: x�2,x1/2.

4.1.2 Derivatives of trigonometric functions, exponential, andlog

Memorizing these results will simplify our life considerably.

Page 21: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

4.1. DIFFERENTIATION 21

1. d(sin(x))dx = cosx and d(cos(x))

dx =�sinx.

2. d(exp(x))/dx = exp(x)

3. d(log(x))/dx = 1x

Proofs will come later.

4.1.3 Derivations of combinations of functionsLet u and v be (differentiable) functions.

1. Sum of functions(u+ v)0 = u0+ v0 (4.9)

2. Difference of functions(u� v)0 = u0 � v0 (4.10)

3. Function multiplied by constant:

Given a constant c:(cu)0 = cu0 (4.11)

4. Product of functions

(uv)0 = uv0+ vu0 (4.12)

5. Quotient of functions:

(u/v)0 =vu0 �uv0

v2 (4.13)

6. Chain rule:

If y = g(f(x)), then, letting u=f(x), we get dy/dx = dy/du ·du/dx

Example: y = (x2 +3)7 needs the chain rule.

Note: the notation dydx

����x=a

means: evaluate the derivative at x=a.

Given one of our standard functions above, which I will call f (x), we candifferentiate it repeatedly: f 0, f 00, etc. So:

Page 22: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

22 CHAPTER 4. DIFFERENTIATION AND INTEGRATION

1. f 0(x) = ddx f (x)

2. f 00(x) = d2

dx2 f (x)

3. f 000(x) = d3

dx3 f (x)

4.1.4 Maxima and minima

If we have a function like y = f (x), there may be a point (for some x) where thegraph of this function turns over. For example, in the normal distribution (seechapterrefapps), the graph turns over at the mean.

At this turning point, the slope changes from positive to negative, and is 0 atthe turning point. Therefore,

f 0(x) (4.14)

is an equation whose solution is the point where the graph turns over.

Note that a graph does not necessarily turn over at a point where f 0(x) = 0.Example: y = x3.

> x<-seq(-10,10,by=0.1)> plot(x,x^3,type="l")

Page 23: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

4.1. DIFFERENTIATION 23

−10 −5 0 5 10

−1000

−500

0500

1000

x

x^3

If f 0(x) = 0 at some point x=c, then this point c is called the stationary pointof f (x). This point could be a local maximum or a local minimum. To determinewhether this point is a local maximum or minimum, take the second derivative:f 00(x).

1. If f 0(c) = 0 and f 00(c)< 0, then we have a local maximum.

2. If f 0(c) = 0 and f 00(c)> 0, then we have a local minimum.

3. If f 0(c) = 0 and f 00(c) = 0, then we have either a maximum, mininum, ora stationary point of inflection like in the y = x3 figure above. In this case,examine the sign of f 0(x) on both sides of x = c.

Page 24: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

24 CHAPTER 4. DIFFERENTIATION AND INTEGRATION

4.2 Integration

4.2.1 Riemann sumsA simple example:

Given f(x), the probability density function of the standard normal distribu-tion:

f(x) = 1p2p

e�x2/2

We have to find an approximate value ofˆ 1

0f(x)dx

We divide the interval [0,1] into 10 intervals of width 1/10, and approxi-mate the area under the curve by taking the sum of the 10 rectangles under thecurve. The width of each rectangle will be ∂x = 1/10, and each of the ten xi are1/10,2/10, . . . ,10/10, i.e., i/10, where i = 1, . . . ,10.

The area A can be computed by summing up the areas of the ten rectanges.Each rectangle’s area is length ⇥ width, which is f(xi)⇥∂x. Hence,

A =10

Âi=1

f(xi)∂x =10

Âi=1

1p2p

e�x2i /2 ⇥ 1

10

The constant terms 1p2p and 1

10 can be pulled out of the summation:

A =1p2p

110

10

Âi=1

e�x2i /2

We use R for the above calculations. First, we define the function for e�x2i /2:

> my.fn<-function(x){exp(1)^(-(x^2/2))}

Then we define xi (I made the code very general so that the number of intervalsn can be increased arbitrarily) and plug this into the function:

> n<-10

[1] 10

Page 25: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

4.2. INTEGRATION 25

> x.i<-(1:n)/n

[1] 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0

> A<- ((1/n) * (1/sqrt(2 * pi)) * sum(my.fn(x.i)))

[1] 0.3332945

> A<-round(A,digits=5)

[1] 0.33329

Compare this to the exact value, computed using R:

> fprob2<-function(x){(1/sqrt(2 * pi))*exp(1)^(-(x^2/2))

}> integrate(fprob2,lower=0,upper=1)

0.3413447 with absolute error < 3.8e-15

Answer: The approximate area is: 0.33329. This is a bit lower than the valuecomputed by R, but this is because the ten rectangles fall inside the curve.

> ## As an aside, note that one can get really close> ## to the pnorm value by increasing n,> ## say to a high number like 2000:> n<-2000> ## 2000 rectangles now:> x.i<-(1:n)/n> (A<- ((1/n) * (1/sqrt(2 * pi)) * sum(my.fn(x.i))))

[1] 0.3413055

With 2000 rectangles, we can get a better estimate of the area than with 10rectangles: 0.3413. Compare this with the theoretical value:

> round(pnorm(1)-pnorm(0),4)

[1] 0.3413

4.2.2 Some common integralsˆ1x

dx = log | x |+c (4.15)

ˆlogxdx =

1x+ c (4.16)

Page 26: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

26 CHAPTER 4. DIFFERENTIATION AND INTEGRATION

4.2.3 The Fundamental Theorem of CalculusThe Fundamental Theorem states the following:

Let f be a continuous real-valued function defined on a closed interval [a,b].Let F be the function defined, for all x in [a,b], by

F(x) =ˆ x

af (u)du

Then, F is continuous on [a,b], differentiable on the open interval (a,b), and

F 0(x) = f (x)

for all x in (a,b).

4.2.4 The u-substitutionFrom [8, 306]:

An integral of the formˆ

f (g(x))g0(x)dx (4.17)

can be written asˆ

f (u)du (4.18)

by setting

u = g(x) (4.19)

and

du = g0(x)dx (4.20)

If F is an antiderivative for f, then

ddx

[F(g(x))] ="

by the chain rule

F 0(g(x))g0(x) ="

F 0= f

f (g(x))g0(x) (4.21)

Page 27: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

4.2. INTEGRATION 27

We can obtain the same result by calculating:

ˆf (u)du (4.22)

and then substituting g(x) back in for u:

ˆf (u)du = F(u)+C = F(g(x))+C (4.23)

A frequently occurring type of integral is

ˆg0(x)g(x)

dx (4.24)

Let u = g(x), giving dudx = g0(x), i.e., du = g0(x)dx, so that

ˆg0(x)g(x)

dx =ˆ

1u

du = ln | u |+C (4.25)

Examples:ˆ

tanxdx =ˆ

1cosx

sinxdx

ˆ2x+b

x2 +bx+ cdx

Functions of linear functions: E.g.,´

cos(2x�1)dx. Here, the general formis´

f (ax+b)dx. We do u = ax+b, and then du = adx

Page 28: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

28 CHAPTER 4. DIFFERENTIATION AND INTEGRATION

Using integration by substitution to compute the expectation of astandard normal random variable:The expectation of the standard normal random variable:

E[Z] =1p2p

ˆ •

�•xe�x2/2 dx

Let u =�x2/2.Then, du/dx =�2x/2 =�x. I.e., du =�xdx or �du = xdx.We can rewrite the integral as:

E[Z] =1p2p

ˆ •

�•euxdx

Replacing xdx with �du we get:

� 1p2p

ˆ •

�•eu du

which yields:

� 1p2p

[eu]•�•

Replacing u with �x2/2 we get:

� 1p2p

[e�x2/2]•�• = 0

4.2.5 Change of variables (Gamma functions)We can solve integrals like

ˆ •

0x2e�x5

dx (4.26)

by restating it as the gamma function:

G(z) =ˆ •

0xz�1e�x dx (4.27)

This can be done by, e.g., letting y = x5, so that dy/dx = 5x4, and thereforedx = dy/5x4 = dy/(5⇥ y4/5). This lets us rewrite the above integral in terms of

Page 29: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

4.2. INTEGRATION 29

y:

y2/5

5y4/5 ey dy (4.28)

This has the form of the gamma function, allowing us to state the integral interms of the gamma function.

Note that

G(z) = (z�1)G(z�1) (4.29)

R has a function, gamma, that allows us to compute G(z):

> gamma(2)

[1] 1

> gamma(10)

[1] 362880

> ## this is equal to:> (10-1)*gamma(10-1)

[1] 362880

Page 30: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

30 CHAPTER 4. DIFFERENTIATION AND INTEGRATION

Page 31: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

Chapter 5

Matrix algebra

[Some of this material is based on [5].]A rectangular array of numbers (real numbers in our case) which obeys certain

algebraic rules of operations is a matrix. The main application for us will be insolving systems of linear equations in statistics (and in data mining).

Example of a 2x2 matrix:

> ## a 2x2 matrix:> (m1<-matrix(1:4,2,2))

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

> ## transpose of a matrix:> t(m1)

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

5.1 Introductory concepts

5.1.1 Basic operationsMatrix addition and subtraction are cell-wise operations:

> m1+m1

31

Page 32: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

32 CHAPTER 5. MATRIX ALGEBRA

[,1] [,2][1,] 2 6[2,] 4 8

> m1-m1

[,1] [,2][1,] 0 0[2,] 0 0

Matrix multiplication: Think of this simple situation first, where you have avector of values:

> (m1<-rnorm(5))

[1] 0.38529088 0.46795759 -0.41145474[4] -2.59554337 0.06052214

>

If you want to find out the sum of the squares of these values (nÂ

i=1x2

i ), then you

can multiply each value in m1 with itself, and sum up the result:

> (sum(m1*m1))

[1] 7.277237

Matrix multiplication does exactly the above operation (for arbitrarily largematrices):

> t(m1)%*%m1

[,1][1,] 7.277237

Note that two matrices can only be multiplied if they are conformable: thenumber of columns of the first matrix has to be the same as the number of rows ofthe second matrix.

Scalar matrix multiplication: Multiplying a matrix M with a scalar value justamounts to multiplying the scalar with each cell of the matrix:

> 5*m1

[1] 1.9264544 2.3397880 -2.0572737[4] -12.9777168 0.3026107

Page 33: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

5.1. INTRODUCTORY CONCEPTS 33

5.1.2 Diagonal matrix and identity matrixA diagonal matrix is a square matrix that has zeros in its off-diagonals:

> diag(c(1,2,4))

[,1] [,2] [,3][1,] 1 0 0[2,] 0 2 0[3,] 0 0 4

An identity matrix is a diagonal matrix with 1’s along its diagonal:

> diag(rep(1,3))

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

For a 3x3 identity matrix, we can write I3, and for an nxn identity matrix, In.Multiplying an identity matrix with any (conformable) matrix gives that matrix

back:

> (I<-diag(c(1,1)))

[,1] [,2][1,] 1 0[2,] 0 1

> (m4<-matrix(c(6,7,8,9),2,2))

[,1] [,2][1,] 6 8[2,] 7 9

> (I%*%m4)

[,1] [,2][1,] 6 8[2,] 7 9

> ## the matrix does not have to be square:> (m5<-matrix(c(2,3,6,7,8,9),2,3))

Page 34: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

34 CHAPTER 5. MATRIX ALGEBRA

[,1] [,2] [,3][1,] 2 6 8[2,] 3 7 9

> (I%*%m5)

[,1] [,2] [,3][1,] 2 6 8[2,] 3 7 9

> betterway<-function(n){return(diag(rep(1,n)))

}

5.1.3 Powers of matricesIf A is a square nxn matrix, then we write AA as A2, and so on. If A is diagonal,then AA is just the diagonal matrix with the diagonal elements of A squared:

> m<-diag(c(1,2,3))> ##> m%*%m

[,1] [,2] [,3][1,] 1 0 0[2,] 0 4 0[3,] 0 0 9

For all positive integers m, Imn = In.

5.1.4 Inverse of a matrixIf A,B are square matrices, of order nxn, and the following relation is satisfied:

AB = BA = In (5.1)

then, B is the inverse (it is unique) of A. We write B = A�1. The inverseis analogous to division and allows us to solve matrix equations: AB=C can besolved by post-multiplying both sides by B�1 to get ABB�1 = AI = A =CB�1.

Page 35: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

5.1. INTRODUCTORY CONCEPTS 35

How to find the inverse? Consider a 2x2 matrix A, and consider the equation:✓

a11 a12a21 a22

◆✓x1x2

◆=

✓d1d2

◆(5.2)

We can write this in compact matrix form: Ax=d. If we multiply A and x, weget a system of linear equations:

a11x1 +a12x2 = d1 (5.3)

a21x1 +a22x2 = d2 (5.4)

If we solve these equations, we get (exercise: prove this as homework):

x1 =a22d1 �a12d2

a11a22 �a21a12(5.5)

x2 =�a21d1 +a11d2

a11a22 �a21a12(5.6)

We can now express the solution in matrix form (verify that this is equivalentto the above two equations for x1 and x2):

x =✓

x1x2

◆=

1a11a22 �a21a12

✓a22d1 �a12d2�a21d1 +a11d2

◆=Cd (5.7)

where

C =1

detA

✓a22 �a12�a21 +a11

◆detA = a11a22 �a21a12 (5.8)

Now, if we pre-multiply Ax = d by A�1, we get

A�1Ax = Ix = x = A�1d (5.9)

So, because x = A�1d and x =Cd, it must be the case that A�1 =C.

Note: Multiplying a matrix by its inverse gives an identity matrix (the Rfunction solve computes the inverse of a matrix):

> (m3<-matrix(c(2,3,4,5),2,2))

Page 36: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

36 CHAPTER 5. MATRIX ALGEBRA

[,1] [,2][1,] 2 4[2,] 3 5

> (round(solve(m3)%*%m3))

[,1] [,2][1,] 1 0[2,] 0 1

So:✓a bc d

◆�1= 1

det

✓d �b�c a

Here, det is the determinant. Note that det(m) is going to be the same asdet(m�1).

5.1.4.1 Inverse of a 3⇥3 matrix

Note: you will normally only use solve in R, you won’t be doing this byhand.

Say you are given:

0

@2 0 00 2 10 1 2

1

A

1. Find determinant (the way to do this by hand is explained below). Det(m)=6.

2. Define co-factors of matrix and add alternating +/- signs, then find determi-nants:0

BBBBBBBBBB@

+

����2 11 2

���� �����0 10 2

���� +

����0 20 1

����

�����0 01 2

���� +

����2 00 2

���� �����2 00 1

����

+

����0 02 1

���� �����2 00 1

���� +

����2 00 2

����

1

CCCCCCCCCCA

=

0

@3 0 00 4 �20 �2 4

1

A

3. Then take reflection of the above matrix; here, none is needed because it’ssymmetric. Then multiply by 1/det to get inverse:

Page 37: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

5.1. INTRODUCTORY CONCEPTS 37

16 ⇥

0

@3 0 00 4 �20 �2 4

1

A=

0

@0.5 0 00 2/3 �1/30 �1/3 2/3

1

A

5.1.4.2 Inverse of a product of non-singular matrices

If A and B are non-singular matrices then (AB)�1 = B�1A�1.

5.1.5 Linear independenceConsider a 3x3 matrix. The The rows r1,r2,r3 are linearly dependent if a,b ,g ,not all zero, exist such that ar1 +b r2 + gr3 = (0,0,0).

If the rows or columns of A are linearly dependent, then det A=0 (the matrixis singular, not invertible).

5.1.6 The rank of a matrixThe column rank of a matrix is the maximum number of linearly independentcolumns in the matrix. The row rank is the maximum number of linearly inde-pendent rows. Column rank is always equal to row rank, so we can just call itrank.

5.1.7 More on determinantsThe determinant is a value associated with a square (nxn) matrix.

1. If the determinant is non-zero, the system of linear equations expressed bythe matrix has a unique solution.

2. If the determinant is zero, there are no solutions or many solutions.

3. We can invert a matrix only if its determinant is non-zero. (Inversion ofmatrices turns up a lot).

The determinant of a square matrix can be computed using an in-built R func-tion.

> (m1<-matrix(1:4,2,2))

Page 38: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

38 CHAPTER 5. MATRIX ALGEBRA

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

> det(m1)

[1] -2

5.1.7.1 Computing determinants by hand

Note that you will almost never have to do this by hand, except for exercises.In real work, we just use R.

The det[erminant] of a 2⇥2 matrix like the one below is ad-bc.✓a bc d

The det of a n⇥ n matrix A, n > 2, is computed as follows:

detA =n

Âj=1

(�1)1+ ja1 jdetA1 j (5.10)

An example makes it easier to understand:

A =

0

@1 5 02 4 �10 �2 0

1

A (5.11)

Then, the determinant is (the vectors in red disappear):

detA = 1⇥

0

@1 5 02 4 �10 �2 0

1

A�5⇥

0

@1 5 02 4 �10 �2 0

1

A+0⇥

0

@1 5 02 4 �10 �2 0

1

A

Another trick, for 3x3 matrices for example, is the following (from Vinod’sbook (Hands-on matrix algebra)):

1. Rewrite the matrix

0

@a d gb e hc f i

1

A by repeating the first two columns and col-

oring the matrix in two ways:

0

@a d g a db e h b ec f i c f

1

A and

0

@a d g a db e h b ec f i c f

1

A

Page 39: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

5.2. SOLVING SIMULTANEOUS LINEAR EQUATIONS 39

2. Then write out:

det = aei+dhc+gb f � ceg� f ha� ibd

5.1.8 SingularityIf the determinant of a square matrix is zero, then it can’t be inverted; we say thatthe matrix is singular.

5.2 Solving simultaneous linear equationsWe know how to solve for x and y in these two equations (by eliminating onevariable—this is the method of elimination):

2x+3y =�1 x�2y = 3 (5.12)

But what about:

x+ y = 2 2x+2y = 1 (5.13)

These two equations are contradictory (check this). There is no solution; wecan also say that they are incompatible. Similarly, consider:

x+ y = 2 2x+2y = 4 (5.14)

These are both saying the same thing, and so reduce to one equation, with twounknowns. Therefore, there is an infinity of solutions.

If we have two equations, and the right-hand side has 0 in both equations, theequations are called homogeneous. Here, there are two possibilities:

First, if the equations are equivalent, as in:

x+ y = 0 2x+2y = 0 (5.15)

we again have an infinity of solutions (x=c and y=-c for any value of c).Second, if the equations are not equivalent, as in:

2x+3y = 0 x�2y = 0 (5.16)

they are not incompatible because they have a single, unique solution, x=0,and y=0. This is called the trivial solution.

To summarize: Inhomogeneous and homogeneous equations can have

Page 40: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

40 CHAPTER 5. MATRIX ALGEBRA

1. a unique solution

2. no solution

3. an infinity of solutions

In addition, homogeneous equations that are not equivalent can have a trivialsolution.

It is easy to use the elimination method to solve equations with two unknowns,but for equations with many unknowns, we need different methods to avoid tediumand error-prone calculations.

5.2.1 Gaussian eliminationGiven three (or more) equations like:

x1 +2x2 + x3 = 1 (5.17)

�2x1 +3x2 � x3 =�7 (5.18)

x1 +4x2 �2x3 =�7 (5.19)

There are three elementary row operations that do not affect the solution:

1. Any equation can be multiplied by a non-zero constant

2. any two equations can be interchanged

3. any equation can be replaced the sum of itself and any multiple of anotherequation

It’s easiest to illustrate how these operations lead to a solution with a concreteexample:

Suppose we are given the three equations shown below. We use Gaussianelimination to solve the equations. I will refer to the rows of a matrix by rn,where n refers to the n-th row.

2x + �y + 3z = 8�x + 6y + z = 17�2x + 5y + 3z = 24

(5.20)

Page 41: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

5.2. SOLVING SIMULTANEOUS LINEAR EQUATIONS 41

Unique solution: No solution:

Infinity of solutions: Trivial solution:

Figure 5.1: Visualizing the solutions of simultaneous linear equations in two di-mensions. Three dimensions involves planes intersecting (or not intersecting) in-stead of lines, and higher dimensions are harder to visualize.

Page 42: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

42 CHAPTER 5. MATRIX ALGEBRA

We could write this in matrix form: Ax = d, where

A =

0

@2 �1 3�1 6 1�2 5 3

1

A x =

0

@x1x2x3

1

A d =

0

@8

1724

1

A (5.21)

The general strategy will be to convert the matrix to echelon form and then toreduced echelon form.

A matrix is in echelon form if it has 0’s below the diagonal elements startingfrom the top left. See equation 5.26. A matrix is in reduced echelon form if itin echelon form and has 1’s along the diagonal starting from the top left. Seeequation 5.27.

First, we convert the coefficients into an augmented matrix:0

@2 �1 3 8�1 6 1 17�2 5 3 24

1

A (5.22)

Next, move the third row (r) to second position:0

@2 �1 3 8�2 5 3 24�1 6 1 17

1

A (5.23)

Add r1 to the new r2 :0

@2 �1 3 80 4 6 32�1 6 1 17

1

A (5.24)

Add r1 to 2⇥r3 (this is the new r3):0

@2 �1 3 80 4 6 320 11 5 42

1

A (5.25)

Subtract 11⇥r2 from 4⇥r3. This gives us the echelon form:0

@2 �1 3 80 4 6 320 0 46 184

1

A (5.26)

Page 43: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

5.2. SOLVING SIMULTANEOUS LINEAR EQUATIONS 43

Next, we convert the matrix to reduced echelon form. Divide r1 by 2, and r2by 4, and r3 by 46:

0

@1 �1/2 3/2 40 1 6/4 80 0 1 4

1

A (5.27)

Next, we eliminate the nonzero values to the right of the 1’s in each row.Subtract 1.5 times r3 from r2

0

@1 �1/2 3/2 40 1 0 20 0 1 4

1

A (5.28)

Add 1.5⇥r2 to r1:0

@1 0 3/2 50 1 0 20 0 1 4

1

A (5.29)

Subtract 1.5r3 from r1:0

@1 0 0 �10 1 0 20 0 1 4

1

A (5.30)

This tells us that x =�1, y = 2, z = 4.Answer: x =�1, y = 2, z = 4.

How to solve multiple-variable simultaneous linear equations in R:

> X <- matrix(c(2,-1,3,-1,6,1,-2,5,3), ncol=3,byrow=T)> y<-c(8,17,24)> library(MASS)> ## correct:> fractions(solve(crossprod(X))%*%crossprod(X,y))

[,1][1,] -1[2,] 2[3,] 4

Page 44: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

44 CHAPTER 5. MATRIX ALGEBRA

You can use Gaussian elimination to find the inverse of a matrix:

AA�1 = I (5.31)

Apply a sequence of row operations that transform A into I on the left-handside, so that the left hand side becomes A�1. Apply the same sequence of rowoperations to I on the right-hand side, and you will get A�1. The two examplesbelow illustrate this point.

Example 1: Find the inverse of

M1 =

0

@1 0 0�1 5 30 3 2

1

A

The algorithm is: row-reduce the augmented matrix [M1I]. If M1 is row equiv-alent to I, then [M1I] is row equivalent to [IM�1

1 ]. Otherwise M1 doesn’t have aninverse.

First, we append the identity matrix to the right side of M1:

[M1I] =

0

@1 0 0 1 0 0�1 5 3 0 1 00 3 2 0 0 1

1

A

The next step is to convert the left half of the matrix [M1I] into an identitymatrix.

Add r1 to r2:

0

@1 0 0 1 0 0

�1+1 5+0 3+0 0+1 1+0 0+00 3 2 0 0 1

1

A=

0

@1 0 0 1 0 00 5 3 1 1 00 3 2 0 0 1

1

A

Subtract 5⇥r3 from 3⇥r2 and place the result in r3:0

@1 0 0 1 0 00 5 3 1 1 00 0 �1 3 3 �5

1

A

Multiply r3 by �1:0

@1 0 0 1 0 00 5 3 1 1 00 0 1 �3 �3 5

1

A

Page 45: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

5.2. SOLVING SIMULTANEOUS LINEAR EQUATIONS 45

Divide r2 by 5:0

@1 0 0 1 0 00 1 3/5 1/5 1/5 00 0 1 �3 �3 5

1

A

Subtract r2 from 3/5⇥r3 and place the result in r2:0

@1 0 0 1 0 00 �1 0 �2 �2 30 0 1 �3 �3 5

1

A

Multiply r2 by �1:0

@1 0 0 1 0 00 1 0 2 2 �30 0 1 �3 �3 5

1

A

The inverse of M1 is therefore:

M�11 =

0

@1 0 02 2 �3�3 �3 5

1

A

We cross-check this with R:

> ## correct:> M1<-matrix(c(1,0,0,-1,5,3,0,3,2),byrow=T,nrow=3)> ## note: ginv is in library MASS, loaded earlier> fractions(ginv(M1))

[,1] [,2] [,3][1,] 1 0 0[2,] 2 2 -3[3,] -3 -3 5

We check our result regarding the inverse by evaluating M1M�11 . If the product

of this matrix multiplication is I, then M�11 is the correct inverse.

M1M�11 =

0

@1 0 0�1 5 30 3 2

1

A

0

@1 0 02 2 �3�3 �3 5

1

A

Page 46: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

46 CHAPTER 5. MATRIX ALGEBRA

The result is:

M1M�11 =

0

@1 ·1+2 ·0+�3 ·0 0 ·1+2 ·0+�3 ·0 0 ·1+�3 ·0+5 ·0

1 ·�1+2 ·5+�3 ·3 0 ·�1+2 ·5+�3 ·3 0 ·�1+�3 ·5+5 ·31 ·0+2 ·3+�3 ·2 0 ·0+2 ·3+�3 ·2 0 ·0+�3 ·3+5 ·2

1

A

Simplifying:

M1M�11 =

0

@1 0 00 1 00 0 1

1

A

This confirms that we have the correct inverse.We cross-check our calculations using R:

> M1<-matrix(c(1,0,0,-1,5,3,0,3,2),byrow=T,nrow=3)> ## correct:> fractions(M1%*%fractions(ginv(M1)))

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

Answer: The inverse of

0

@1 0 0�1 5 30 3 2

1

A is

0

@1 0 02 2 �3�3 �3 5

1

A.

Example 2: Find the inverse of M2:

M2 =

0

@1 0 0�1 6 40 3 2

1

A

First, we augment the matrix:

M2I =

0

@1 0 0 1 0 0�1 6 4 0 1 00 3 2 0 0 1

1

A

We replace r2 with r1 +r2:

Page 47: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

5.3. EIGENVALUES AND EIGENVECTORS 47

M2I =

0

@1 0 0 1 0 00 6 4 1 1 00 3 2 0 0 1

1

A

Divide r2 by 2:

M2I =

0

@1 0 0 1 0 00 3 2 1/2 1/2 00 3 2 0 0 1

1

A

There is no way to proceed here since the second and third rows can never bechanged such that we have an identity matrix on the left hand side. I.e., no inverseexists for this matrix.

We cross-check this result using R by computing the inverse and then multi-plying the original matrix with the purported inverse; we should get the identitymatrix. As the R code shows, we do not get the identity matrix.

> M2<-matrix(c(1,0,0,-1,6,4,0,3,2),byrow=T,nrow=3)> ## should have been an identity matrix:> fractions(M2%*%fractions(ginv(M2)))

[,1] [,2] [,3][1,] 5/6 -1/6 1/3[2,] -1/6 5/6 1/3[3,] 1/3 1/3 1/3

Answer: M2 does not have an inverse because it is not row equivalent to I.

5.3 Eigenvalues and eigenvectorsAny set of equations Ax=0 is a homogeneous set. Clearly, this will have at leastthe trivial solution x=0. The more interesting question is: are there any non-trivialsolutions? It turns out that such a set of equations will have non-trivial solutionsonly if det A is 0.

Now consider the nxn set of equations: Ax = lx or (A�l I)x = 0. In orderfor these equations to have non-trivial solutions, it must be true (see previousparagraph) that

det(A�l I) = 0 (5.32)

Page 48: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

48 CHAPTER 5. MATRIX ALGEBRA

The above is called the characteristic equation of A, and the l that satisfythe equation are called eigenvalues.

Example:Find the eigenvalues of

A =

✓1 32 2

Solve det(A�l I) = 0:

det✓

1�l 32 2�l

◆= (1�l )(2�l )�6 ) l 2 �3l �4 = 0 (5.33)

This gives us the factorization (l �4)(l +1). It follows that the eigenvaluesare l1 =�1,l2 = 4 (we will order them from smallest to largest).

Recall the rule for figuring out the roots of a quadratic equation:�b±

pb2�4ac

2a

Associated with each eigenvalue we have a non-trivial solution to the equation(A�l I)x = 0. Each of the solutions corresponding to each eigenvalue is calledthe eigenvector. So, once you have found an eigenvalue l1, you can find the eigen-vector by solving the simultaneous linear equation (A�l1I)x = 0 using Gaussianelimination.

For our above example, we have l1 =�1,l2 = 4. So, the eigenvectors are:

s1 =

✓a1b1

◆s2 =

✓a2b2

◆(5.34)

Recall that A =

✓1 32 2

◆.

We need to find the two solutions: (A�l1I)s1 = 0 and (A�l2I)s2 = 0.As an example, consider (A�l1I)s2 = 0. Expanding everything out:

✓1 32 2

◆�✓

4 00 4

◆✓a2b2

◆=

✓00

◆(5.35)

This gives us:✓�3 32 �2

◆✓a2b2

◆=

✓00

◆(5.36)

Page 49: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

5.3. EIGENVALUES AND EIGENVECTORS 49

The solution is a2 = b2 = a for any value a .You can do a similar calculation to get the eigenvector s1.Normally, we will use R for calculating eigenvalues and eigenvectors:

> m<-matrix(c(1,3,2,2),byrow=T,ncol=2)> eigen(m)

$values[1] 4 -1

$vectors[,1] [,2]

[1,] -0.7071068 -0.8320503[2,] -0.7071068 0.5547002

However, you should know how to do this by hand for 2x2 matrices; for largermatrices, just use R.

Note that a zero eigenvalue implies that A is singular, i.e., det A = 0. If Asingular, then A has at least one 0 eigenvalue.

5.3.1 Linear dependenceConsider the set of all mx1 column vectors; this set is the m-dimensional vectorspace Vm. Thus, if

s1 =

0

BBB@

a1a2...

am

1

CCCAs2 =

0

BBB@

b1b2...

bm

1

CCCA(5.37)

Then s1 and s2 belong to Vm and so does

as1 +b s2 (5.38)for any a and b .We refer to as the set of base vectors in Vm the following:

e1 =

0

BBB@

10...0

1

CCCAe2 =

0

BBB@

01...0

1

CCCA. . .em =

0

BBB@

00...1

1

CCCA(5.39)

Page 50: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

50 CHAPTER 5. MATRIX ALGEBRA

Any vector in Vm can be expressed as a linear combination of these vectors:For any i = 1, . . . ,m,

si = a1e1 + · · ·+amem (5.40)

This is why e1, . . . ,em forms a basis for Vm. Note that none of the ei can be ex-pressed as a linear combination of the others; i.e., they are linearly independent.

The set of n column vectors s1, . . . ,sn is said to be linearly dependent if thereexists constants a1, . . . ,an (not all zero) such that

a1s1 + · · ·+ansn = 0 (5.41)

If the above equation holds only when a1 = · · ·= an = 0, then the s1 . . .sn arelinearly dependent.

Note that any set of m linearly independent vectors form a basis of the vectorspace Vm.

Example:The column vectors below for a basis in three dimensions: a1 = [1,1,0]T ,a2 =

[1,0,1]T ,a3 = [0,0,1]T .To show this, we have to verify that

xa1 + ya2 + za3 = 0 (5.42)

has non-zero solutions for x, y, z. We are trying to solve the equations:0

@x + y = 0x + z = 0

y + z = 0

1

A (5.43)

The coefficient matrix is:0

@1 1 01 0 10 1 1

1

A (5.44)

Its determinant is -2 (i.e., not 0). The only solution is x = y = z = 0. Thereforethe vectors are linearly independent, and can form a basis.

For a square matrix A, if det A = 0, there is an infinite number of non-trivialsolutions. If detA 6== 0, the only solution is x = 0.

Page 51: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

5.3. EIGENVALUES AND EIGENVECTORS 51

5.3.2 Diagonalization of a matrixThe eigenvalue and eigenvector information contained in a matrix can be used ina useful factorization of the type D =C�1AC where D is a diagonal matrix. Sincecomputing powers of a diagonal matrix D are easy, we can use this factorizationto find powers of the matrix A very quickly (see section 5.1.3).

Consider the matrix m and its eigenvalues and eigenvectors:

> m<-matrix(c(1,2,1,2,1,1,1,1,2),byrow=FALSE,nrow=3)

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

> eigen_values_m<-eigen(m)$values

[1] 4 1 -1

> eigen_vectors_m<-eigen(m)$vectors

[,1] [,2] [,3][1,] -0.5773503 -0.4082483 7.071068e-01[2,] -0.5773503 -0.4082483 -7.071068e-01[3,] -0.5773503 0.8164966 -8.881784e-16

Note that the eigenvectors are linearly independent, and do the matrix is non-singular:

> det(eigen_vectors_m)

[1] -1

Let the matrix of eigenvectors (eigen_vectors_m above) be the matrix C.Note that AC = A[s1 s2 s3], where s1,s2,s3 are the eigenvectors of A. Now, si is bydefinition a non-zero solution to Asi = l1si.

Let D be the diagonal matrix of eigenvalues:

D =

0

@l1 0 00 l2 00 0 l3

1

A (5.45)

Now,

AC =CD (5.46)

Page 52: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

52 CHAPTER 5. MATRIX ALGEBRA

[Verify this.]Pre-multiplying both sides with C�1, we get:

C�1AC =C�1CD = D (5.47)

We say that the operation C�1AC has diagonalized the matrix A.Summary of steps: To diagonalize a matrix A:

1. find the eigenvalues of A

2. find n linearly independent eigenvectors sn of A (if they exist)

3. construct the matrix C of eigenvectors

4. calculate the inverse of C

5. compute C�1AC

5.3.2.1 Application of diagonalization: finding powers of matrices

For a diagonal matrix D, we can find any power Dn quickly by just raising thediagonal elements dii to the n-th power.

To find the power of any matrix A, first note that:

AC =CD (5.48)

Post-multiplying both sides by C�1, we get:

ACC�1 = A =CDC�1 (5.49)

It follows that

A2 =CDC�1CDC�1 =CDDC�1 =CD2C�1 (5.50)

A3 =CDC�1CDC�1CDC�1 =CD3C�1 (5.51)

and in general, it should be obvious that:

An =

n timesz }| {CDC�1CDC�1 . . .CDC�1CDC�1 =CDnC�1 (5.52)

Page 53: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

5.3. EIGENVALUES AND EIGENVECTORS 53

5.3.3 Quadratic formsLet x= [x1,x2, . . . ,xn]T be an n-dimensional column vector. Any polynomial func-tion of these elements in which every term is of degree 2 in them is called aquadratic form. For n=3, we have (for example):

x21 +8x1x2 +6x2x3 + x2

3 (5.53)

Quadratic forms can always be expressed in matrix form:

xT Ax (5.54)

The above example in equation 5.53 can be restated as:

�x1 x2 x3

�0

@1 4 04 1 30 3 1

1

A

0

@x1x2x3

1

A (5.55)

Note that A is a symmetric matrix. Any quadratic form can be written using asymmetric A (although non-symmetric representations are possible).

Now let’s compute the eigenvalues and eigenvectors:

> m<-matrix(c(1,4,0,4,1,3,0,3,1),byrow=FALSE,ncol=3)

[,1] [,2] [,3][1,] 1 4 0[2,] 4 1 3[3,] 0 3 1

> val<-eigen(m)$values

[1] 6 1 -4

> vec<-eigen(m)$vectors

[,1] [,2] [,3][1,] 0.5656854 -6.000000e-01 -0.5656854[2,] 0.7071068 -6.661338e-16 0.7071068[3,] 0.4242641 8.000000e-01 -0.4242641

Note that the eigenvectors are orthogonal:

> round(t(vec[,1])%*%vec[,2],5)

[,1][1,] 0

Page 54: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

54 CHAPTER 5. MATRIX ALGEBRA

> round(t(vec[,1])%*%vec[,3],5)

[,1][1,] 0

> round(t(vec[,2])%*%vec[,3],5)

[,1][1,] 0

[Two vectors an and bn are orthogonal when aT b = 0. We say that they aremutually perpendicular.]

This property of orthogonality comes from the fact that the matrix is symmet-ric:

Theorem 1. If A is a real symmetric matrix, then the eigenvectors associated withany two distinct eigenvalues are orthogonal.

5.3.3.1 Positive-definite matrices

A quadratic form is positive definite if xT Ax > 0 for all x 6= 0. The matrix A isalso called positive definite.

A symmetric matrix A is positive definite if and only if its eigenvalues arepositive.

There is a unique decomposition of A

A = LLT (5.56)

where L is the lower triangular matrix (this matrix has non-zero values in thelower-triangular part, and 0’s in the upper triangular part). The equation 5.56 iscalled the Cholesky decomposition. How to compute this in R:

> m <- matrix(c(5,1,1,3),2,2)> L <- t(chol(m))> L%*%t(L)

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

There is also a unique decomposition of A such that

A =V DV T V TV = I (5.57)

is called the singular value decomposition.

Page 55: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

Chapter 6

Multivariate calculus

6.1 Partial derivativesIt is easy to imagine that more than one variable may be involved in a function:

z = f (x,y) = x3 + y3

We will encounter such functions in multivariate statistics (see chapter 7).We will say that we are taking a partial derivative if we differentiate a function

like z above with respect to x (treating y as a constant) or with respect to y (treatingx as a constant).

We write these two cases as ∂ f (x,y)∂x and ∂ f (x,y)

∂y . Higher derivatives can becomputed in the usual way we have seen.

We can also take mixed derivatives, where we first differentiate f(x,y) withrespect to x and then with respect to y; this is written:

∂ 2 f (x,y)∂∂y

Note that order of differentiation does not matter for the kinds of functions wewill encounter: ∂ 2 f (x,y)

∂x∂y = ∂ 2 f (x,y)∂y∂x .

6.2 Drawing level curvesYou can draw contour plots of a bivariate function, also called level curves, givenx and y values stored in a matrix m (x in the first column, and y in the second).

> ## source:> #https://stat.ethz.ch/pipermail/r-help/> ##2007-October/142470.html

55

Page 56: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

56 CHAPTER 6. MULTIVARIATE CALCULUS

> dens2d<-function(x, nx = 20, ny = 20,margin = 0.05, h = 1)

{xrange <- max(x[, 1]) - min(x[, 1])yrange <- max(x[, 2]) - min(x[, 2])xmin <- min(x[, 1]) - xrange * marginxmax <- max(x[, 1]) + xrange * marginymin <- min(x[, 2]) - yrange * marginymax <- max(x[, 2]) + yrange * marginxstep <- (xmax - xmin)/(nx - 1)ystep <- (ymax - ymin)/(ny - 1)xx <- xmin + (0:(nx - 1)) * xstepyy <- ymin + (0:(ny - 1)) * ystepg <- matrix(0, ncol = nx, nrow = ny)n <- dim(x)[[1]]for(i in 1:n) {coefx <- dnorm(xx - x[i, 1], mean = 0, sd = h)coefy <- dnorm(yy - x[i, 2], mean = 0, sd = h)g <- g + coefx %*% t(coefy)/n}return(list(x = xx, y = yy, z = g))}

> m<-matrix(cbind(x=rnorm(10),y=rnorm(10)),ncol=2)

> contour(dens2d(m))

Page 57: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

6.3. DOUBLE INTEGRALS 57

0.04 0.04

0.045

0.05

0.05

0.05

0.055

0.055

0.055 0.06

0.06

0.06

0.065

0.065

0.07

0.075

0.08

0.085

0.09

−1.5 −1.0 −0.5 0.0 0.5

−1.0

−0.5

0.0

0.5

1.0

1.5

2.0

6.3 Double integrals

6.3.1 How to solve double integralsAn example may help in seeing how to solve double integrals. Let

I =ˆ 1

0

ˆ 2

0(xy+ y2 �1)dxdy (6.1)

1. Put brackets around the inner integral, and relabel the limits so that it isclear which integral is for which variable:

I =ˆ 1

y=0

✓ˆ 2

x=0(xy+ y2 �1)dx

◆dy (6.2)

Page 58: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

58 CHAPTER 6. MULTIVARIATE CALCULUS

2. Treat y as a constant and evaluate the inner integral with respect to x:

✓ˆ 2

x=0(xy+ y2 �1)dx

◆=

12

x2y+ xy2 � x�2

x=0= 2y+2y2 �2 (6.3)

Note that x has been eliminated.

3. Use the result of the inner integration for the second integral:

ˆ 1

y=02y+2y2 �2dy =

y2 +

23

y3 �2y�1

y=0= 1� 2

3�2 =�1

3(6.4)

See the section on jointly distributed random variables (page 91, section 7.4)for some applications of double integrals in statistics.

6.3.2 Double integrals using polar coordinatesAny (x,y) point in a cartesian plane can be stated in terms of the angle q of theline from the origin to the point (x,y), and the length r of the line from the originto the point (x,y). Recall that

cosq =xr

sinq =yr

(6.5)

Therefore, x = r cosq ,y = r sinq .It is easier to solve the double integral

˜(1� x2 � y2)dxdy, (where x2 + y2 <

1;x,y < 1) if we convert to polar coordinates.Note that

˜(1� x2 � y2)dxdy is just a sum of all the areas of small near-

rectangles; we can call the areas dA:¨

f (x,y)dA (6.6)

Now, given a small rectangle with side dr, and a small angle dq , its area willbe rdrdq , because the arc’s length will be (by the definition of radian) rdq , thewidth of the rectangle is dr. See Figure 6.1.

Page 59: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

6.3. DOUBLE INTEGRALS 59

> library(plotrix)> plot(0:2,0:2,type="n",xlab="",ylab="")> draw.circle(0,0,1,border="black",lty=1,lwd=1)> arrows(x0=0,y0=0,x1=.7,y1=.7,code=2,length=0)> arrows(x0=0,y0=0,x1=.45,y1=.9,code=2,length=0)> draw.circle(0,0,.7,border="black",lty=2,lwd=1)> draw.circle(0,0,.9,border="black",lty=2,lwd=1)> text(.48,.75,"dA",cex=2)> text(.4,.6,expression(paste("rd",theta)),cex=1)> text(.6,.55,"dr",cex=1)

0.0 0.5 1.0 1.5 2.0

0.0

0.5

1.0

1.5

2.0

dArdθ dr

Figure 6.1: The function f(x,y). (The circle has not been drawn correctly. Need tofix this.)

Page 60: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

60 CHAPTER 6. MULTIVARIATE CALCULUS

So, in polar coordinate terms, our integral will look like:

¨f (x,y)dA=

¨(1�x2�y2)rdrdq =

¨(1�(x2+y2))rdrdq =

¨(1�r2)rdrdq

(6.7)The last line above holds because r2 = x2 + y2 by Pythagoras’ theorem.Next, we define the upper and lower bounds of the integrals; we can do this

because we are given that x2 + y2 < 1;x,y < 1. This describes a quarter circle onthe first quadrant of the cartesian plane, with radius 1.

¨(1� r2)rdrdq =

ˆ p/2

0

ˆ 1

0(1� r2)rdrdq

=

ˆ p/2

0[r2

2� r4

4]10 dq

=

ˆ p/2

0

14

dq

=p8

(6.8)

More generally, if the region R is the region a r b,a q b , then

¨R

f (x,y)dxdy =ˆ b

a

ˆ b

af (r,q)rdrdq (6.9)

This change of variables is related to the next topic.

6.3.3 The Jacobian in a change of variables transformationWe just saw that it is sometimes convenient to transform a function that is in termsof x,y, into another function in terms of u,v (above, we transformed to r, q ).

Suppose we need to solve˜( x

a)2 +( y

b)2 dxdy, given that ( x

a)2 +( y

b)2 < 1. We

are basically looking to find the area inside an ellipse.

> plot(c(-10,10), c(-10,10), type="n",main="Ellipse with a=3,b=2")

> draw.ellipse(c(0,0),c(0,0),a=3,b=2,angle=0)

Page 61: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

6.3. DOUBLE INTEGRALS 61

−10 −5 0 5 10

−10

−50

510

Ellipse with a=3,b=2

c(−10, 10)

c(−1

0, 1

0)

To make this integral simpler to solve, we can change variables. Say x/a =u,y/b = v. Now our region R is u2 + v2 < 1. This looks much easier to solvebecause it is a circle now, with radius 1. Remember that its area is going to p .

x/a = u implies du = 1a dx

y/b = v implies dv = 1b dy

So, dudv = 1ab dxdy. Or, dxdy = abdudv. So, in the double integral, I can

replace dxdy with abdudv:¨

R(u2 + v2)abdudv = ab

¨R

u2 + v2dudv = abp (6.10)

(because the area of a unit circle is p).When we want to find the area in a double integral with variables x and y, the

area will be dA= dxdy. When we transform the variables to u,v, the area in the u,vdimensions will be dA0 = dudv. To take a concrete example, suppose u = 3x�2yand v = x+y. Then dA will be the area of a rectangle, and the dA0 will be the areaof a parallelogram (the transformation just twists the rectangle in the x,y space to

Page 62: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

62 CHAPTER 6. MULTIVARIATE CALCULUS

a parallelogram in u,v space). The area dA will not be the same as the are dA’;i.e., there is some scaling factor k such that dA = kdA0.

As a concrete example, consider the unit square:

> plot(c(0,1.25), c(0,1.25), type="n", main="Unit square")> arrows(x0=1,y0=0,x1=1,y1=1,code=2,length=0)> arrows(x0=1,y0=1,x1=0,y1=1,code=2,length=0)> arrows(x0=0,y0=0,x1=0,y1=1,code=2,length=0)> arrows(x0=0,y0=0,x1=1,y1=0,code=2,length=0)

0.0 0.2 0.4 0.6 0.8 1.0 1.2

0.0

0.2

0.4

0.6

0.8

1.0

1.2

Unit square

c(0, 1.25)

c(0,

1.2

5)

In u,v terms, we have a paralleogram:

> plot(c(-3,3), c(-3,3), type="n", main="Unit square")> arrows(x0=0,y0=0,x1=3,y1=1,code=2,length=0)> arrows(x0=3,y0=1,x1=1,y1=2,code=2,length=0)> arrows(x0=1,y0=2,x1=-2,y1=1,code=2,length=0)> arrows(x0=-2,y0=1,x1=0,y1=0,code=2,length=0)

Page 63: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

6.3. DOUBLE INTEGRALS 63

> text(2,1,"(u1=3,u2=1)",cex=1)> text(-1,1,"(v1=-2,v2=1)",cex=1)

−3 −2 −1 0 1 2 3

−3−2

−10

12

3

Unit square

c(−3, 3)

c(−3

, 3)

(u1=3,u2=1)(v1=−2,v2=1)

Now, it can be shown that the area (dA0) of a parallegram is the length of thecross-product of the two vectors that make up two vectors u and v. That can beshown to be the absolute value of the determinant of the matrix A:

A =

✓u1 u2v1 v2

◆=

✓u1 = 3 u2 = 1

v1 =�2 v2 = 1

◆(6.11)

Now, | detA |= u1v2 � u2v1 = 5. That means that the parallelogram has fivetimes the size than the unit square. So there is always a scaling factor neededwhen we do a change of variables.

So, in the above example, dA0 = 5dA, i.e., dudv = 5dxdy. If we are integratingin terms of u,v, we have to correct for the fact that the area in u,v coordinates is 5

Page 64: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

64 CHAPTER 6. MULTIVARIATE CALCULUS

times larger:¨

. . .dxdy =¨

. . .15

dudv (6.12)

The scaling factor 15 is called the Jacobian. We could have written¨

. . .dxdy =¨

. . .1

| detA |dudv (6.13)

We say that the Jacobian J=det A, where A is the relevant matrix. I discussthis matrix next by considering the general case.

Let u = f (x,y), and v = g(x,y), i.e., u and v are some functions of x and y. Letf and g be continuously differentiable functions over some region G. The point(u,v) generates a region W in the u-v plane: (f(x,y),g(x,y)). The Jacobian in thiscase can be computed by:

J(x,y) =∂ (u,v)∂ (x,y)

= det

∂u∂x

∂v∂x

∂u∂y

∂v∂y

!(6.14)

The main thing to understand here is that the Jacobian is the scaling factorwhen you change variables.

To express a double integral in new coordinatesIf x = g(u,v),y = h(u,v), then:

¨E

f (x,y)dxdy =¨

Sf (g(u,v),h(u,v)) | ∂ (x,y)

∂ (u,v)| dudv (6.15)

S is the region R transformed to the cartesian u-v plane.

Page 65: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

Chapter 7

Some background in statistics, withapplications of mathematicalmethods

The tools we’ve acquired in this course have applications in many areas of science,but in the MSc in Cognitive Systems we are mainly interested in their applicationsfor statistics and (by extension) data mining.

We begin by considering some facts about random variables. Then we lookat how expectation and variance etc. are computed. Several typical probabilitydistributions and their properties are discussed. Two major applications of themathematics we covered are in maximum likelihood estimation and in the matrixformulation of linear models.

7.1 Discrete random variables; ExpectationA random variable X is a function X : S ! R that associates to each outcomew 2 S exactly one number X(w) = x.

SX is all the x’s (all the possible values of X, the support of X). I.e., x 2 SX .Good example: number of coin tosses till H

• X : w ! x

• w: H, TH, TTH,. . . (infinite)

• x = 0,1,2, . . . ;x 2 SX

65

Page 66: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

66CHAPTER 7. SOME BACKGROUND IN STATISTICS, WITH APPLICATIONS OF MATHEMATICAL METHODS

Every discrete random variable X has associated with it a probability mass/distributionfunction (PDF), also called distribution function.

pX : SX ! [0,1] (7.1)

defined by

pX(x) = P(X(w) = x),x 2 SX (7.2)

[Note: Books sometimes abuse notation by overloading the meaning of X .They usually have: pX(x) = P(X = x),x 2 SX ]

The cumulative distribution function is

F(a) = Âall xa

p(x) (7.3)

Basic results:

E[X ] =n

Âi=1

xi p(xi) (7.4)

E[g(X)] =n

Âi=1

g(xi)p(xi) (7.5)

Var(X) = E[(X �µ)2] (7.6)

Var(X) = E[X2]� (E[X ])2 (7.7)

Var(aX +b) = a2Var(X) (7.8)

SD(X) =p

Var(X) (7.9)

For two independent random variables X and Y ,

E[XY ] = E[X ]E[Y ] (7.10)

Covariance of two random variables:

Cov(X ,Y ) = E[(X �E[X ])(Y �E[Y ])] (7.11)

Page 67: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

7.1. DISCRETE RANDOM VARIABLES; EXPECTATION 67

Note that Cov(X,Y)=0 if X and Y are independent.Corollary in 4.1 of [7]:

E[aX +b] = aE[X ]+b (7.12)

A related result is about linear combinations of RVs:Theorem. Given two not necessarily independent random variables X and

Y:

E[aX +bY ] = aE[X ]+bE[Y ] (7.13)

If X and Y are independent,

Var(X +Y ) =Var[X ]+Var[Y ] (7.14)

and

Var(aX +bY ) = a2Var(X)+b2Var(Y ) (7.15)

If a = 1,b =�1, then

Var(X �Y ) =Var(X)+Var(Y ) (7.16)

If X and Y are not independent, then

Var(X �Y ) =Var(X)+Var(Y )�2Cov(X ,Y ) (7.17)

7.1.1 Examples of discrete probability distributions7.1.1.1 Geometric

Suppose that independent trials are performed, each with probability p, where0 < p < 1, until a success occurs. Let X equal the number of trials required.Then,

P(X = n) = (1� p)n�1 p n = 1,2, . . . (7.18)

Note that:

Âx=0

p(1� p)x =p•

Âx=0

qx = p1

1�q= 1.

Page 68: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

68CHAPTER 7. SOME BACKGROUND IN STATISTICS, WITH APPLICATIONS OF MATHEMATICAL METHODS

The mean and variance are

µ =1� p

p=

qp

and s2 =qp2 . (7.19)

7.1.1.2 Negative binomial

[Taken nearly verbatim from [6].]Consider the case where we wait for more than one success. Suppose that we

conduct Bernoulli trials repeatedly, noting the respective successes and failures.Let X count the number of failures before r successes. If P(S) = p then X hasPMF

fX(x) =✓

r+ x�1r�1

◆pr(1� p)x, x = 0,1,2, . . . (7.20)

We say that X has a Negative Binomial distribution and write X ⇠ nbinom(size=r, prob= p).

Note that fX(x)� 0 and the fact that  fX(x) = 1 follows from a generalizationof the geometric series by means of a Maclaurin’s series expansion:

11� t

=•

Âk=0

tk, for �1 < t < 1, and (7.21)

1(1� t)r =

Âk=0

✓r+ k�1

r�1

◆tk, for �1 < t < 1. (7.22)

Therefore

Âx=0

fX(x) = pr•

Âx=0

✓r+ x�1

r�1

◆qx = pr(1�q)�r = 1, (7.23)

since | q |=| 1� p |< 1.

7.2 Continuous random variablesRecall from the discrete random variables section that: A random variable Xis a function X : S !R that associates to each outcome w 2 S exactly one numberX(w) = x. SX is all the x’s (all the possible values of X, the support of X). I.e.,x 2 SX .

Page 69: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

7.2. CONTINUOUS RANDOM VARIABLES 69

X is a continuous random variable if there is a non-negative function f definedfor all real x 2 (�•,•) having the property that for any set B of real numbers,

P{X 2 B}=ˆ

Bf (x)dx (7.24)

Kerns has the following to add about the above:

Continuous random variables have supports that look like

SX = [a,b] or (a,b), (7.25)

or unions of intervals of the above form. Examples of random vari-ables that are often taken to be continuous are:

• the height or weight of an individual,

• other physical measurements such as the length or size of anobject, and

• durations of time (usually).

Every continuous random variable X has a probability density func-tion (PDF) denoted fX associated with it that satisfies three basicproperties:

1. fX(x)> 0 for x 2 SX ,

2.´

x2SXfX(x)dx = 1, and

3. P(X 2 A) =´

x2A fX(x)dx, for an event A ⇢ SX .

We can say the following about continuous random variables:

• Usually, the set A in condition 3 above takes the form of aninterval, for example, A = [c,d], in which case

P(X 2 A) =ˆ d

cfX(x)dx. (7.26)

• It follows that the probability that X falls in a given interval issimply the area under the curve of fX over the interval.

Page 70: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

70CHAPTER 7. SOME BACKGROUND IN STATISTICS, WITH APPLICATIONS OF MATHEMATICAL METHODS

• Since the area of a line x = c in the plane is zero, P(X = c) =0 for any value c. In other words, the chance that X equalsa particular value c is zero, and this is true for any number c.Moreover, when a < b all of the following probabilities are thesame:

P(a X b) = P(a < X b) = P(a X < b) = P(a < X < b).(7.27)

• The PDF fX can sometimes be greater than 1. This is in contrastto the discrete case; every nonzero value of a PMF is a probabil-ity which is restricted to lie in the interval [0,1].

f (x) is the probability density function of the random variable X .Since X must assume some value, f must satisfy

1 = P{X 2 (�•,•)}=ˆ •

�•f (x)dx (7.28)

If B = [a,b], then

P{a X b}=ˆ b

af (x)dx (7.29)

If a = b, we get

P{X = a}=ˆ a

af (x)dx = 0 (7.30)

Hence, for any continuous random variable,

P{X < a}= P{X a}= F(a) =ˆ a

�•f (x)dx (7.31)

F is the cumulative distribution function. Differentiating both sides in theabove equation:

dF(a)da

= f (a) (7.32)

The density (PDF) is the derivative of the CDF. In the discrete case [6, 128]:

fX(x) = FX(x)� limt!x�

FX(t) (7.33)

Page 71: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

7.3. IMPORTANT CLASSES OF CONTINUOUS RANDOM VARIABLES 71

Ross [7] says that it is more intuitive to think about it as follows:

P{a� e2 X a+

e2}=ˆ a+e/2

a�e/2f (x)dx ⇡ e f (a) (7.34)

when e is small and when f (·) is continuous. I.e., e f (a) is the approximateprobability that X will be contained in an interval of length e around the point a.

Basic results (proofs omitted):1.

E[X ] =

ˆ •

�•x f (x)dx (7.35)

2.E[g(X)] =

ˆ •

�•g(x) f (x)dx (7.36)

3.E[aX +b] = aE[X ]+b (7.37)

4.Var[X ] = E[(X �µ)2] = E[X2]� (E[X ])2 (7.38)

5.Var(aX +b) = a2Var(X) (7.39)

7.3 Important classes of continuous random vari-ables

7.3.1 Uniform random variableA random variable (X) with the continuous uniform distribution on the interval(a,b ) has PDF

fX(x) =

(1

b�a , a < x < b ,0, otherwise

(7.40)

The associated R function is dunif(min= a, max= b). We write X ⇠ unif(min=a, max = b). Due to the particularly simple form of this PDF we can also write

Page 72: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

72CHAPTER 7. SOME BACKGROUND IN STATISTICS, WITH APPLICATIONS OF MATHEMATICAL METHODS

down explicitly a formula for the CDF FX :

FX(a) =

8><

>:

0, a < 0,a�ab�a , a t < b ,1, a � b .

(7.41)

E[X ] =b +a

2(7.42)

Var(X) =(b �a)2

12(7.43)

7.3.2 Normal random variable

fX(x) =1

sp

2pe�(x�µ)2

2s2 , �• < x < •. (7.44)

We write X ⇠ norm(mean = µ, sd = s), and the associated R function isdnorm(x, mean = 0, sd = 1).

> plot(function(x) dnorm(x), -3, 3,main = "Normal density",ylim=c(0,.4),

ylab="density",xlab="X")

If X is normally distributed with parameters µ and s2, then Y = aX + b isnormally distributed with parameters aµ +b and a2s2.

Computing areas under the curve with R:

> integrate(function(x) dnorm(x, mean = 0, sd = 1),lower=-Inf,upper=Inf)

1 with absolute error < 9.4e-05

> ## alternatively:> pnorm(Inf)-pnorm(-Inf)

[1] 1

> integrate(function(x) dnorm(x, mean = 0, sd = 1),lower=-2,upper=2)

0.9544997 with absolute error < 1.8e-11

> ## alternatively:> pnorm(2)-pnorm(-2)

Page 73: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

7.3. IMPORTANT CLASSES OF CONTINUOUS RANDOM VARIABLES 73

−3 −2 −1 0 1 2 3

0.0

0.1

0.2

0.3

0.4

Normal density

X

density

Figure 7.1: Normal distribution.

Page 74: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

74CHAPTER 7. SOME BACKGROUND IN STATISTICS, WITH APPLICATIONS OF MATHEMATICAL METHODS

[1] 0.9544997

> integrate(function(x) dnorm(x, mean = 0, sd = 1),lower=-1,upper=1)

0.6826895 with absolute error < 7.6e-15

> ## alternatively:> pnorm(1)-pnorm(-1)

[1] 0.6826895

7.3.2.1 Standard or unit normal random variable

If X is normally distributed with parameters µ and s2, then Z = (X � µ)/s isnormally distributed with parameters 0,1.

We conventionally write F(x) for the CDF:

F(x) =1p2p

ˆ x

�•e�y2

2 dy wherey = (x�µ)/s (7.45)

Neave’s tables give the values for positive x; for negative x we do:

F(�x) = 1�F(x), �• < x < • (7.46)

If Z is a standard normal random variable (SNRV) then

p{Z �x}= P{Z > x}, �• < x < • (7.47)

Since Z = ((X �µ)/s) is an SNRV whenever X is normally distributed withparameters µ and s2, then the CDF of X can be expressed as:

FX(a) = P{X a}= P✓

X �µs

a�µs

◆= F

✓a�µ

s

◆(7.48)

The standardized version of a normal random variable X is used to computespecific probabilities relating to X (it’s also easier to compute probabilities fromdifferent CDFs so that the two computations are comparable).

The expectation of the standard normal random variable:

E[Z] =1p2p

ˆ •

�•xe�x2/2 dx

Page 75: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

7.3. IMPORTANT CLASSES OF CONTINUOUS RANDOM VARIABLES 75

Let u =�x2/2.Then, du/dx =�2x/2 =�x. I.e., du =�xdx or �du = xdx.We can rewrite the integral as:

E[Z] =1p2p

ˆ •

�•euxdx

Replacing xdx with �du we get:

� 1p2p

ˆ •

�•eu du

which yields:

� 1p2p

[eu]•�•

Replacing u with �x2/2 we get:

� 1p2p

[e�x2/2]•�• = 0

The variance of the standard normal distribution:We know that

Var(Z) = E[Z2]� (E[Z])2

Since (E[Z])2 = 0 (see immediately above), we have

Var(Z) = E[Z2] =1p2p

ˆ •

�•x2"

This is Z2.

e�x2/2 dx

Write x2 as x⇥ x and use integration by parts:

1p2p

ˆ •

�•x"u

xe�x2/2"

dv/dx

dx =1p2p

x"u

�e�x2/2"v

� 1p2p

ˆ •

�•�e�x2/2

"v

1"

du/dx

dx = 1

[Explained on p. 274 of [4]; it wasn’t obvious to me, and [7, 200] is prettyterse]: “The first summand above can be shown to equal 0, since as x ! ±•,e�x2/2 gets small more quickly than x gets large. The second summand is just thestandard normal density integrated over its domain, so the value of this summandis 1. Therefore, the variance of the standard normal density equals 1.”

Page 76: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

76CHAPTER 7. SOME BACKGROUND IN STATISTICS, WITH APPLICATIONS OF MATHEMATICAL METHODS

Example: Given N(10,16), write distribution of X , where n = 4. Since SE =sd/sqrt(n), the distribution of X is N(10,4/

p4).

7.3.3 Exponential random variablesFor some l > 0,

f (x) =⇢

le�lx if x � 00 if x < 0.

A continuous random variable with the above PDF is an exponential randomvariable (or is said to be exponentially distributed).

The CDF:

F(a) =P(X a)

=

ˆ a

0le�lx dx

=h�e�lx

ia

0

=1� e�la a � 0

[Note: the integration requires the u-substitution: u =�lx, and then du/dx =�l , and then use �du = ldx to solve.]

7.3.3.1 Expectation and variance of an exponential random variable

For some l > 0 (called the rate), if we are given the PDF of a random variable X :

f (x) =⇢

le�lx if x � 00 if x < 0.

Find E[X].[This proof seems very strange and arbitrary—one starts really generally and

then scales down, so to speak. The standard method can equally well be used,but this is more general, it allows for easy calculation of the second moment, forexample. Also, it’s an example of how reduction formulae are used in integration.]

E[Xn] =

ˆ •

0xnle�lx dx

Page 77: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

7.3. IMPORTANT CLASSES OF CONTINUOUS RANDOM VARIABLES 77

Use integration by parts:Let u = xn, which gives du/dx = nxn�1. Let dv/dx = le�lx, which gives

v =�e�lx. Therefore:

E[Xn] =

ˆ •

0xnle�lx dx

=h�xne�lx

i•

0+

ˆ •

0elxnxn�1 dx

=0+nl

ˆ •

0le�lxnn�1 dx

Thus,

E[Xn] =nl

E[Xn�1]

If we let n = 1, we get E[X ]:

E[X ] =1l

Note that when n = 2, we have

E[X2] =2l

E[X ] =2

l 2

Variance is, as usual,

var(X) = E[X2]� (E[X ])2 =2

l 2 � (1l)2 =

1l 2

7.3.4 Weibull distributionf (x | a,b ) = ab (bx)a�1 exp(�(bx)a) (7.49)

When a = 1, we have the exponential distribution.

7.3.5 Gamma distribution[The text is an amalgam of [6] and [7, 215]. I don’t put it in double-quotes as acitation because it would look ugly.]

Page 78: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

78CHAPTER 7. SOME BACKGROUND IN STATISTICS, WITH APPLICATIONS OF MATHEMATICAL METHODS

This is a generalization of the exponential distribution. We say that X has agamma distribution and write X ⇠ gamma(shape = a, rate = l ), where a > 0(called shape) and l > 0 (called rate). It has PDF

f (x) =

(le�lx(lx)a�1

G(a) if x � 00 if x < 0.

G(a) is called the gamma function:

G(a) =

ˆ •

0e�yya�1 dy =

"integration by parts

(a �1)G(a �1)

Note that for integral values of n, G(n) = (n� 1)! (follows from above equa-tion).

The associated R functions are gamma(x, shape, rate = 1), pgamma,qgamma, and rgamma, which give the PDF, CDF, quantile function, and simu-late random variates, respectively. If a = 1 then X ⇠ exp(rate = l ). The meanis µ = a/l and the variance is s2 = a/l 2.

To motivate the gamma distribution recall that if X measures the length of timeuntil the first event occurs in a Poisson process with rate l then X ⇠ exp(rate=l ). If we let Y measure the length of time until the a th event occurs then Y ⇠gamma(shape = a, rate = l ). When a is an integer this distribution is alsoknown as the Erlang distribution.

> ## fn refers to the fact that it> ## is a function in R, it does not mean that> ## this is the gamma function:> gamma.fn<-function(x){

lambda<-1alpha<-1(lambda * exp(1)^(-lambda*x) *(lambda*x)^(alpha-1))/gamma(alpha)

}> x<-seq(0,4,by=.01)> plot(x,gamma.fn(x),type="l")

The Chi-squared distribution is the gamma distribution with l = 1/2 and a =n/2, where n is an integer:

Page 79: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

7.3. IMPORTANT CLASSES OF CONTINUOUS RANDOM VARIABLES 79

0 1 2 3 4

0.0

0.2

0.4

0.6

0.8

1.0

x

gamma.fn(x)

Figure 7.2: The gamma distribution..

Page 80: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

80CHAPTER 7. SOME BACKGROUND IN STATISTICS, WITH APPLICATIONS OF MATHEMATICAL METHODS

> gamma.fn<-function(x){lambda<-1/2alpha<-8/2 ## n=4(lambda * (exp(1)^(-lambda*x)) *(lambda*x)^(alpha-1))/gamma(alpha)

}> x<-seq(0,100,by=.01)> plot(x,gamma.fn(x),type="l")

0 20 40 60 80 100

0.00

0.02

0.04

0.06

0.08

0.10

x

gamma.fn(x)

Figure 7.3: The chi-squared distribution.

7.3.5.1 Mean and variance of gamma distribution

Let X be a gamma random variable with parameters a and l .

Page 81: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

7.3. IMPORTANT CLASSES OF CONTINUOUS RANDOM VARIABLES 81

E[X ] =1

G(a)

ˆ •

0xle�lx(lx)a�1 dx

=1

lG(a)

ˆ •

0e�lx(lx)a dx

=G(a +1)lG(a)

=al

see derivation of G(a), p. 215 of [7]

It is easy to show (exercise) that

Var(X) =al 2

7.3.6 Memoryless property (Poisson, Exponential, Geometric)A nonnegative random variable is memoryless if

P(X > s+ t) | X > t) = P(X > s) for all s, t � 0

Two equivalent ways of stating this:

P(X > s+ t,X > t)P(X > t)

= P(X > s)

[just using the definition of conditional probability]or

P(X > s+ t) = P(X > s)P(X > t)

[not clear yet why the above holds]Recall definition of conditional probability:

P(B | A) =P(A\B)P(A) , if P(A)> 0.

What memorylessness means is: let s = 10 and t = 30. Then

P(X > 10+30,X � 30)P(X � 30)

= P(X > 10)

Page 82: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

82CHAPTER 7. SOME BACKGROUND IN STATISTICS, WITH APPLICATIONS OF MATHEMATICAL METHODS

or

P(X > 10+30) = P(X > 10)P(X � 30)

It does not mean:

P(X > 10+30 | X � 30) = P(X > 40)

It’s easier to see graphically what this means:

> fn<-function(x,lambda){lambda*exp(1)^(-lambda*x)

}> x<-seq(0,1000,by=1)> plot(x,fn(x,lambda=1/100),type="l")> abline(v=200,col=3,lty=3)> abline(v=300,col=1,lty=3)

> x1<-seq(300,1300,by=1)> plot(x1,fn(x1,lambda=1/100),type="l")

7.3.6.1 Examples of memorylessness

Suppose we are given that a discrete random variable X has probability functionq x�1(1�q), where x = 1,2, . . . . Show that

P(X > t +a | X > a) =P(X > t +a)

P(X > a)(7.50)

hence establishing the ‘absence of memory’ property:

P(X > t +a | X > a) = P(X > t) (7.51)

Proof:First, restate the pdf given so that it satisfies the definition of a geometric

distribution. Let q = 1� p; then the pdf is

(1� p)x�1 p (7.52)

Page 83: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

7.3. IMPORTANT CLASSES OF CONTINUOUS RANDOM VARIABLES 83

0 200 400 600 800 1000

0.00

00.

002

0.00

40.

006

0.00

80.

010

x

fn(x

, lam

bda

= 1/

100)

Figure 7.4: The memoryless property of the exponential distribution. The graphafter point 300 is an exact copy of the original graph (this is not obvious fromthe graph, but redoing the graph starting from 300 makes this clear, see figure 7.5below).

Page 84: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

84CHAPTER 7. SOME BACKGROUND IN STATISTICS, WITH APPLICATIONS OF MATHEMATICAL METHODS

400 600 800 1000 1200

0e+0

01e−0

42e−0

43e−0

44e−0

45e−0

4

x1

fn(x

1, la

mbd

a =

1/10

0)

Figure 7.5: Replotting the distribution starting from 300 instead of 0, and ex-tending the x-axis to 1300 instead of 1000 (the number in figure 7.4) gives us anexact copy of original. This is the meaning of the memoryless property of thedistribution.

Page 85: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

7.3. IMPORTANT CLASSES OF CONTINUOUS RANDOM VARIABLES 85

This is clearly a geometric random variable (see p. 155 of Ross [7]). On p.156, Ross points out that

P(X > a) = (1� p)a (7.53)

[Actually Ross points out that P(X � k) = (1� p)k�1, from which it followsthat P(X � k+1) = (1� p)k; and since P(X � k+1) = P(X > k), we have P(X >k) = (1� p)k.]

Similarly,

P(X > t) = (1� p)t (7.54)

and

P(X > t +a) = (1� p)t+a (7.55)

Now, we plug in the values for the right-hand side in equation 7.50, repeatedbelow:

P(X > t +a | X > a) =P(X > t +a)

P(X > a)=

(1� p)t+a

(1� p)a = (1� p)t (7.56)

Thus, since P(X > t) = (1� p)t (see above), we have proved that

P(X > t +a | X > a) = P(X > t) (7.57)

This is the definition of memorylessness (equation 5.1 in Ross [7], p. 210). There-fore, we have proved the memorylessness property.

7.3.6.2 Prove the memorylessness property for Gamma and Exponentialdistributions

Exponential:The CDF is:

P(a) = 1� e�la (7.58)

Page 86: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

86CHAPTER 7. SOME BACKGROUND IN STATISTICS, WITH APPLICATIONS OF MATHEMATICAL METHODS

Therefore:

P(X > s+t)= 1�P(s+t)= 1�(1�e�l (s+t))= e�l (s+t) = e�l se�l t =P(X > s)P(X > t)(7.59)

The above is the definition of memorylessness.

Gamma distribution:The CDF (not sure how this comes about, see Ross [7]) is

F(x;a,b ) = 1�a�1

Âi=0

1i!(bx)ie�bx (7.60)

Therefore,

P(X > s+t)= 1�P(X < s+t)= 1�(1�a�1

Âi=0

1i!(b (s+t))ie�b (s+t))=

a�1

Âi=0

1i!(b (s+t))ie�b (s+t)

(7.61)

7.3.7 Beta distributionThis is a generalization of the continuous uniform distribution.

f (x) =

(1

B(a,b)xa�1(1� x)b�1 if 0 < x < 1

0 otherwise

where

B(a,b) =ˆ 1

0xa�1(1� x)b�1 dx

There is a connection between the beta and the gamma:

B(a,b) =ˆ 1

0xa�1(1� x)b�1 dx =

G(a)G(b)G(a+b)

which allows us to rewrite the beta PDF as

f (x) =G(a+b)G(a)G(b)

xa�1(1� x)b�1, 0 < x < 1. (7.62)

Page 87: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

7.3. IMPORTANT CLASSES OF CONTINUOUS RANDOM VARIABLES 87

The mean and variance are

E[X ] =a

a+band Var(X) =

ab(a+b)2 (a+b+1)

. (7.63)

7.3.8 Distribution of a function of a random variable (transfor-mations of random variables)

A nice and intuitive description:Consider a continuous RV Y which is a continuous differentiable increasing

function of X:

Y = g(X) (7.64)

Because g is differentiable and increasing, g0 and g�1 are guaranteed to exist.Because g maps all x s x+Dx to y s y+Dy, we can say:

ˆ x+Dx

xfX(s)ds =

ˆ y+Dy

yfY (t)dt (7.65)

Therefore, for small Dx:

fY (y)Dy ⇡ fX(x)Dx (7.66)

Dividing by Dy we get:

fY (y)⇡ fX(x)DxDy

(7.67)

Theorem 2 (Theorem 7.1 in Ross [7]). Let X be a continuous random variablehaving probability density function fX . Suppose that g(x) is a strict monotone(increasing or decreasing) function, differentiable and (thus continuous) functionof x. Then the random variable Y defined by Y = g(X) has a probability densityfunction defined by

fY (y) =⇢

fX(g�1(y)) | ddxg�1(y) | if y = g(x) for some x

0 if y 6= g(x) for all x.

where g�1(y) is defined to be equal to the value of x such that g(y� y).

Page 88: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

88CHAPTER 7. SOME BACKGROUND IN STATISTICS, WITH APPLICATIONS OF MATHEMATICAL METHODS

Proof:Suppose y = g(x) for some x. Then, with Y = g(X),

FY (y) =P(g(X) y)

=P(X g�1(y))

=FX(g�1(y))

(7.68)

Differentiation gives

fY (y) = fX(g�1(y))d(g�1(y))

dy(7.69)

Detailed explanation for the above equation: Since

FY (y) =FX(g�1(y))

=

ˆfX(g�1(y))dy

(7.70)

Differentiating:

d(FY (y))dy

=ddy

(FX(g�1(y))) (7.71)

We use the chain rule. To simplify things, rewrite w(y) = g�1(y) (otherwisetypesetting things gets harder). Then, let

u = w(y)

which gives

dudy

= w0(y)

and let

x = FX(u)

This gives us

Page 89: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

7.3. IMPORTANT CLASSES OF CONTINUOUS RANDOM VARIABLES 89

dxdu

= F 0X(u) = fX(u)

By the chain rule:

dudy

⇥ dxdu

= w0(y) fX(u) ="

plugging in the variables

ddy

(g�1(y)) fX(g�1(y))

Exercises:1. Y = X2

2. Y =p

X

3. Y =| X |

4. Y = aX +b

7.3.9 The Poisson distributionAs Kerns [6] puts it (I quote him nearly exactly, up to the definition):

This is a distribution associated with “rare events”, for reasons whichwill become clear in a moment. The events might be:

• traffic accidents,

• typing errors, or

• customers arriving in a bank.

Let l be the average number of events in the time interval [0,1]. Letthe random variable X count the number of events occurring in theinterval. Then under certain reasonable conditions it can be shownthat

fX(x) = P(X = x) = e�l l x

x!, x = 0,1,2, . . . (7.72)

Page 90: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

90CHAPTER 7. SOME BACKGROUND IN STATISTICS, WITH APPLICATIONS OF MATHEMATICAL METHODS

7.3.9.1 Poisson conditional probability and binomial

If X1 ⇠ Pois(l1) and X2 ⇠ Pois(l2) are independent and Y = X1 +X2, then thedistribution of X1 conditional on Y = y is a binomial. Specifically, X1 | Y = y ⇠Binom(y,l1)/(l1,l2). More generally, if X1,X2, . . . ,Xn are independent Poissonrandom variables with parameters l1,l2, . . . ,ln then

Xi |n

Âj=1

Xj ⇠ Binom(n

Âj=1

Xj,linl jj=1

) (7.73)

[Source for above: wikipedia]. Relevant for q3 in P-Ass 5.To see why this is true, see p. 173 of Dekking et al. Also see the stochastic

processes book.

7.3.10 Geometric distribution [discrete]

From Ross [7, 155]:

Let independent trials, each with probability p, 0 < p < 1 of success,be performed until a success occurs. If X is the number of trials re-quired till success occurs, then

P(X = n) = (1� p)n�1 p n = 1,2, . . .

I.e., for X to equal n, it is necessary and sufficient that the first n�1are failures, and the nth trial is a success. The above equation comesabout because the successive trials are independent.

X is a geometric random variable with parameter p.Note that a success will occur, with probability 1:

Âi=1

P(X = n) = p•

Âi=1

(1� p)n�1 ="

see geometric series section.

p1� (1� p)

= 1

Page 91: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

7.4. JOINTLY DISTRIBUTED RANDOM VARIABLES 91

7.3.10.1 Mean and variance of the geometric distribution

E[X ] =1p

Var(X) =1� p

p2

For proofs, see Ross [7, 156-157].

7.3.11 Normal approximation of the binomial and poissonExcellent explanation available at:

http://www.johndcook.com/normal_approx_to_poisson.html

If P(X = n) use P(n�0.5 < X < n+0.5)If P(X > n) use P(X > n+0.5)If P(X n) use P(X < n+0.5)If P(X < n) use P(X < n�0.5)If P(X � n) use P(X > n�0.5)

7.4 Jointly distributed random variables

7.4.1 Joint distribution functions7.4.1.1 Discrete case

[This section is an extract from [6].]Consider two discrete random variables X and Y with PMFs fX and fY that are

supported on the sample spaces SX and SY , respectively. Let SX ,Y denote the set ofall possible observed pairs (x,y), called the joint support set of X and Y . Thenthe joint probability mass function of X and Y is the function fX ,Y defined by

fX ,Y (x,y) = P(X = x, Y = y), for (x,y) 2 SX ,Y . (7.74)

Every joint PMF satisfies

fX ,Y (x,y)> 0 for all (x,y) 2 SX ,Y , (7.75)

Page 92: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

92CHAPTER 7. SOME BACKGROUND IN STATISTICS, WITH APPLICATIONS OF MATHEMATICAL METHODS

and

Â(x,y)2SX ,Y

fX ,Y (x,y) = 1. (7.76)

It is customary to extend the function fX ,Y to be defined on all of R2 by settingfX ,Y (x,y) = 0 for (x,y) 62 SX ,Y .

In the context of this chapter, the PMFs fX and fY are called the marginalPMFs of X and Y , respectively. If we are given only the joint PMF then we mayrecover each of the marginal PMFs by using the Theorem of Total Probability:observe

fX(x) = P(X = x), (7.77)= Â

y2SY

P(X = x, Y = y), (7.78)

= Ây2SY

fX ,Y (x,y). (7.79)

By interchanging the roles of X and Y it is clear that

fY (y) = Âx2SX

fX ,Y (x,y). (7.80)

Given the joint PMF we may recover the marginal PMFs, but the converse isnot true. Even if we have both marginal distributions they are not sufficient todetermine the joint PMF; more information is needed.

Associated with the joint PMF is the joint cumulative distribution functionFX ,Y defined by

FX ,Y (x,y) = P(X x, Y y), for (x,y) 2 R2.

The bivariate joint CDF is not quite as tractable as the univariate CDFs, but in prin-ciple we could calculate it by adding up quantities of the form in Equation 7.74.The joint CDF is typically not used in practice due to its inconvenient form; onecan usually get by with the joint PMF alone.

Page 93: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

7.4. JOINTLY DISTRIBUTED RANDOM VARIABLES 93

Examples from [6]: Example 1:Roll a fair die twice. Let X be the face shown on the first roll, and let Y bethe face shown on the second roll. For this example, it suffices to define

fX ,Y (x,y) =1

36, x = 1, . . . ,6, y = 1, . . . ,6.

The marginal PMFs are given by fX(x) = 1/6, x = 1,2, . . . ,6, and fY (y) =1/6, y = 1,2, . . . ,6, since

fX(x) =6

Ây=1

136

=16, x = 1, . . . ,6,

and the same computation with the letters switched works for Y .Here, and in many other ones, the joint support can be written as a productset of the support of X “times” the support of Y , that is, it may be repre-sented as a cartesian product set, or rectangle, SX ,Y = SX ⇥ SY , whereSX ⇥ SY = {(x,y) : x 2 SX , y 2 SY}. This form is a necessary condi-tion for X and Y to be independent (or alternatively exchangeable whenSX = SY ). But please note that in general it is not required for SX ,Y to beof rectangle form.Example 2: very involved example in [6], worth study.

7.4.1.2 Continuous case

For random variables X and y, the joint cumulative pdf is

F(a,b) = P(X a,Y b) �• < a,b < • (7.81)

The marginal distributions of FX and FY are the CDFs of each of the associ-ated RVs:

1. The CDF of X :

FX(a) = P(X a) = FX(a,•) (7.82)

2. The CDF of Y :

FY (a) = P(Y b) = FY (•,b) (7.83)

Page 94: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

94CHAPTER 7. SOME BACKGROUND IN STATISTICS, WITH APPLICATIONS OF MATHEMATICAL METHODS

Definition 1. Jointly continuous: Two RVs X and Y are jointly continuous if thereexists a function f (x,y) defined for all real x and y, such that for every set C:

P((X ,Y ) 2C) =

¨

(x,y)2C

f (x,y)dxdy (7.84)

f (x,y) is the joint PDF of X and Y .Every joint PDF satisfies

f (x,y)� 0 for all (x,y) 2 SX ,Y , (7.85)

and ¨

SX ,Y

f (x,y)dxdy = 1. (7.86)

For any sets of real numbers A and B, and if C = {(x,y) : x 2 A,y 2 B}, itfollows from equation 7.84 that

P((X 2 A,Y 2 B) 2C) =

ˆB

ˆA

f (x,y)dxdy (7.87)

Note that

F(a,b) = P(X 2 (�•,a]),Y 2 (�•,b])) =ˆ b

�•

ˆ a

�•f (x,y)dxdy (7.88)

Differentiating, we get the joint pdf:

f (a,b) =∂ 2

∂a∂bF(a,b) (7.89)

One way to understand the joint PDF:

P(a < X < a+da,b < Y < b+db) =ˆ d+db

b

ˆ a+da

af (x,y)dxdy ⇡ f (a,b)dadb

(7.90)Hence, f (x,y) is a measure of how probable it is that the random vector (X ,Y )

will be near (a,b).

Page 95: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

7.4. JOINTLY DISTRIBUTED RANDOM VARIABLES 95

7.4.1.3 Marginal probability distribution functions

If X and Y are jointly continuous, they are individually continuous, and their PDFsare:

P(X 2 A) =P(X 2 A,Y 2 (�•,•))

=

ˆA

ˆ •

�•f (x,y)dydx

=

ˆA

fX(x)dx

(7.91)

where

fX(x) =ˆ •

�•f (x,y)dy (7.92)

Similarly:

fY (y) =ˆ •

�•f (x,y)dx (7.93)

7.4.1.4 Independent random variables

Random variables X and Y are independent iff, for any two sets of real numbers Aand B:

P(X 2 A,Y 2 B) = P(X 2 A)P(Y 2 B) (7.94)

In the jointly continuous case:

f (x,y) = fX(x) fY (y) for all x,y (7.95)

A necessary and sufficient condition for the random variables X and Y to beindependent is for their joint probability density function (or joint probability massfunction in the discrete case) f (x,y) to factor into two terms, one depending onlyon x and the other depending only on y. This can be stated as a proposition:

Proposition 1.

Page 96: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

96CHAPTER 7. SOME BACKGROUND IN STATISTICS, WITH APPLICATIONS OF MATHEMATICAL METHODS

Easy-to-understand example from [6]: Let the joint PDF of (X ,Y ) begiven by

fX ,Y (x,y) =65�x+ y2� , 0 < x < 1, 0 < y < 1.

The marginal PDF of X is

fX(x) =

ˆ 1

0

65�x+ y2� dy,

=65

✓xy+

y3

3

◆����1

y=0,

=65

✓x+

13

◆,

for 0 < x < 1, and the marginal PDF of Y is

fY (y) =

ˆ 1

0

65�x+ y2� dx,

=65

✓x2

2+ xy2

◆����1

x=0,

=65

✓12+ y2

◆,

for 0 < y < 1.In this example the joint support set was a rectangle [0,1]⇥ [0,1], but itturns out that X and Y are not independent. This is because 6

5�x+ y2�

cannot be stated as a product of two terms ( fX(x) fY (y)).

7.4.1.5 Sums of independent random variables

[Taken nearly verbatim from Ross.]

Suppose that X and Y are independent, continuous random variables havingprobability density functions fX and fY . The cumulative distribution function of

Page 97: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

7.4. JOINTLY DISTRIBUTED RANDOM VARIABLES 97

X +Y is obtained as follows:

FX+Y (a) =P(X +Y a)

=

¨

x+ya

fXY (x,y)dxdy

=

¨

x+ya

fX(x) fY (y)dxdy

=

ˆ •

�•

ˆ a�y

�•fX(x) fY (y)dxdy

=

ˆ •

�•

ˆ a�y

�•fX(x)dx fY (y)dy

=

ˆ •

�•FX(a� y) fY (y)dy

(7.96)

The CDF FX+Y is the convolution of the distributions FX and FY .If we differentiate the above equation, we get the pdf fX+Y :

fX+Y =ddx

ˆ •

�•FX(a� y) fY (y)dy

=

ˆ •

�•

ddx

FX(a� y) fY (y)dy

=

ˆ •

�•fX(a� y) fY (y)dy

(7.97)

7.4.2 Conditional distributions

7.4.2.1 Discrete case

Recall that the conditional probability of B given A, denoted P(B | A), is definedby

P(B | A) =P(A\B)P(A) , if P(A)> 0. (7.98)

Page 98: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

98CHAPTER 7. SOME BACKGROUND IN STATISTICS, WITH APPLICATIONS OF MATHEMATICAL METHODS

If X and Y are discrete random variables, then we can define the conditionalPMF of X given that Y = y as follows:

pX |Y (x | y) =P(X = x | Y = y)

=P(X = x,Y = y)

P(Y = y)

=p(x,y)pY (y)

(7.99)

for all values of y where pY (y) = P(Y = y)> 0.The conditional cumulative distribution function of X given Y = y is de-

fined, for all y such that pY (y)> 0, as follows:

FX |Y =P(X x | Y = y)

=Âax

pX |Y (a | y) (7.100)

If X and Y are independent then

pX |Y (x | y) = P(X = x) = pX(x) (7.101)

See the examples starting p. 264 of Ross.An important thing to understand is the phrasing of the question (e.g., in P-

Ass3): “Find the conditional distribution of X given all the possible values ofY ”.

7.4.2.2 Continuous case

[Taken almost verbatim from Ross.]If X and Y have a joint probability density function f (x,y), then the conditional

probability density function of X given that Y = y is defined, for all values of ysuch that fY (y)> 0,by

fX |Y (x | y) =f (x,y)fY (y)

(7.102)

Page 99: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

7.4. JOINTLY DISTRIBUTED RANDOM VARIABLES 99

We can understand this definition by considering what fX |Y (x | y)dx amountsto:

fX |Y (x | y)dx =f (x,y)fY (y)

dxdydy

=f (x,y)dxdy

fY (y)dy

=P(x < X < d +dx,y < Y < y+dy)

y < P < y+dy

(7.103)

7.4.3 Joint and marginal expectation[Taken nearly verbatim from [6].]

Given a function g with arguments (x,y) we would like to know the long-runaverage behavior of g(X ,Y ) and how to mathematically calculate it. Expectationin this context is computed by integrating (summing) with respect to the jointprobability density (mass) function.

Discrete case:

Eg(X ,Y ) = ÂÂ(x,y)2SX ,Y

g(x,y) fX ,Y (x,y). (7.104)

Continuous case:

Eg(X ,Y ) =¨

SX ,Y

g(x,y) fX ,Y (x,y)dxdy, (7.105)

7.4.3.1 Covariance and correlation

There are two very special cases of joint expectation: the covariance and thecorrelation. These are measures which help us quantify the dependence betweenX and Y .

Definition 2. The covariance of X and Y is

Cov(X ,Y ) = E(X �EX)(Y �EY ). (7.106)

Page 100: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

100CHAPTER 7. SOME BACKGROUND IN STATISTICS, WITH APPLICATIONS OF MATHEMATICAL METHODS

Shortcut formula for covariance:

Cov(X ,Y ) = E(XY )� (EX)(EY ). (7.107)

The Pearson product moment correlation between X and Y is the covariancebetween X and Y rescaled to fall in the interval [�1,1]. It is formally defined by

Corr(X ,Y ) =Cov(X ,Y )

sX sY. (7.108)

The correlation is usually denoted by rX ,Y or simply r if the random vari-ables are clear from context. There are some important facts about the correlationcoefficient:

1. The range of correlation is �1 rX ,Y 1.

2. Equality holds above (rX ,Y = ±1) if and only if Y is a linear function of Xwith probability one.

Discrete example: to-do

Page 101: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

7.4. JOINTLY DISTRIBUTED RANDOM VARIABLES 101

Continuous example from [6]: Let us find the covariance of the variables (X ,Y )from an example numbered 7.2 in Kerns. The expected value of X is

EX =

ˆ 1

0x · 6

5

✓x+

13

◆dx =

25

x3 +15

x2����1

x=0=

35,

and the expected value of Y is

EY =

ˆ 1

0y · 6

5

✓12+ y2

◆dx =

310

y2 +3

20y4����1

y=0=

920

.

Finally, the expected value of XY is

EXY =

ˆ 1

0

ˆ 1

0xy

65�x+ y2�dxdy,

=

ˆ 1

0

✓25

x3y+310

xy4◆����

1

x=0dy,

=

ˆ 1

0

✓25

y+3

10y4◆

dy,

=15+

350

,

which is 13/50. Therefore the covariance of (X ,Y ) is

Cov(X ,Y ) =1350

�✓

35

◆✓9

20

◆=� 1

100.

7.4.4 Conditional expectation

Recall that

fX |Y (x | y) = P(X = x | Y = y) =pX ,Y (x,y)

pY (y)(7.109)

for all y such that P(Y = y)> 0.

Page 102: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

102CHAPTER 7. SOME BACKGROUND IN STATISTICS, WITH APPLICATIONS OF MATHEMATICAL METHODS

It follows that

E[X | Y = y] =Âx

xP(X = x | Y = y)

=Âx

xpX |Y (x | y)(7.110)

E[X | Y ] is that function of the random variable Y whose value at Y = y isE[X | Y = y]. E[X | Y ] is a random variable.

7.4.4.1 Relationship to ‘regular’ expectation

Conditional expectation given that Y = y can be thought of as being an ordinaryexpectation on a reduced sample space consisting only of outcomes for whichY = y. All properties of expectations hold. Two examples:

Example 1:

E[g(X) | Y = y] =

(Âx

g(x)pX |Y (x,y) in the discrete case´ •�• g(x) fX |Y (x | y)dx in the continuous case

Example 2:

E

"n

Âi=1

Xi | Y = y

#=

n

Âi=1

E[Xi | Y = y] (7.111)

Proposition 2. Expectation of the conditional expectation

E[X ] = E[E[X | Y ]] (7.112)

If Y is a discrete random variable, then the above proposition states that

E[X ] = Ây

E[X | Y = y]P(Y = y) (7.113)

Page 103: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

7.4. JOINTLY DISTRIBUTED RANDOM VARIABLES 103

7.4.5 Multinomial coefficients and multinomial distributions

[Taken almost verbatim from [6], with some additional stuff from Ross.]

We sample n times, with replacement, from an urn that contains balls of kdifferent types. Let X1 denote the number of balls in our sample of type 1, let X2denote the number of balls of type 2, ..., and let Xk denote the number of ballsof type k. Suppose the urn has proportion p1 of balls of type 1, proportion p2 ofballs of type 2, ..., and proportion pk of balls of type k. Then the joint PMF of(X1, . . . ,Xk) is

fX1,...,Xk(x1, . . . ,xk) =

✓n

x1 x2 · · · xk

◆px1

1 px22 · · · pxk

k , (7.114)

for (x1, . . . ,xk) in the joint support SX1,...XK . We write

(X1, . . . ,Xk)⇠multinom(size= n, prob= pk⇥1). (7.115)

Note:

First, the joint support set SX1,...XK contains all nonnegative integer k-tuples(x1, . . . ,xk) such that x1 + x2 + · · ·+ xk = n. A support set like this is called asimplex. Second, the proportions p1, p2, ..., pk satisfy pi � 0 for all i and p1 +p2 + · · ·+ pk = 1. Finally, the symbol

✓n

x1 x2 · · · xk

◆=

n!x1!x2! · · ·xk!

(7.116)

is called a multinomial coefficient which generalizes the notion of a binomial co-efficient.

Page 104: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

104CHAPTER 7. SOME BACKGROUND IN STATISTICS, WITH APPLICATIONS OF MATHEMATICAL METHODS

Example from Ross:Suppose a fair die is rolled nine times. The probability that 1 appearsthree times, 2 and 3 each appear twice, 4 and 5 each appear once, and 6not at all, can be computed using the multinomial distribution formula.Here, for i = 1, . . . ,6, it is clear that pi == 1

6 . And it is clear that n = 9,and x1 = 3, x2 = 2, x3 = 2, x4 = 1, x5 = 1, and x6 = 0. We plug in thevalues into the formula:

fX1,...,Xk(x1, . . . ,xk) =

✓n

x1 x2 · · · xk

◆px1

1 px22 · · · pxk

k (7.117)

Plugging in the values:

fX1,...,Xk(x1, . . . ,xk) =

✓9

322110

◆16

3 16

2 16

2 16

1 16

1 16

0(7.118)

Answer: 9!3!2!2!

�16�9

7.4.6 Multivariate normal distributionsRecall that in the univariate case:

f (x) =1

p2ps2e{� ( (x�µ)

s )2

2 }�• < x < • (7.119)

We can write the power of the exponential as:

((x�µ)

s)2 = (x�µ)(x�µ)(s2)�1 = (x�µ)(s2)�1(x�µ) = Q (7.120)

Generalizing this to the multivariate case:

Q = (x�µ)0S�1(x�µ) (7.121)

So, for multivariate case:

f (x) =1p

2pdetSe{�Q/2}�• < xi < •, i = 1, . . . ,n (7.122)

Page 105: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

7.5. APPLICATION OF DIFFERENTIATION: METHOD OF MAXIMUM LIKELIHOOD ESTIMATION105

Properties of normal MVN X:

• Linear combinations of X are normal distributions.

• All subset’s of X’s components have a normal distribution.

• Zero covariance implies independent distributions.

• Conditional distributions are normal.

7.5 Application of differentiation: Method of maxi-mum likelihood estimation

For this section, note that if we write the equation f 0(x) = 0, and solve for x,we are basically trying to find out what the value of x is when the slope is 0.That is exactly the situation when the function f “turns”, i.e., is at a maximum orminimum.

Next, we look at an application of differentation that will come up again andagain. In statistics, we look at the sample values and then choose as our estimatesof the unknown parameters the values for which the probability or probabilitydensity of getting the sample values is a maximum.

Discrete case: Suppose the observed sample values are x1,x2, . . . ,xn. Theprobability of getting them is

P(X1 = x1,X2 = x2, . . . ,Xn = xn) = f (X1 = x1,X2 = x2, . . . ,Xn = xn;q) (7.123)

i.e., the function f is the value of the joint probability distribution of the randomvariables X1, . . . ,Xn at X1 = x1, . . . ,Xn = xn. Since the sample values have beenobserved and are fixed, f (x1, . . . ,xn;q) is a function of q . The function f is calleda likelihood function.

Continuous caseHere, f is the joint probability density, the rest is the same as above.

Definition 3. If x1,x2, . . . ,xn are the values of a random sample from a populationwith parameter q , the likelihood function of the sample is given by

L(q) = f (x1,x2, . . . ,xn;q) (7.124)

Page 106: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

106CHAPTER 7. SOME BACKGROUND IN STATISTICS, WITH APPLICATIONS OF MATHEMATICAL METHODS

for values of q within a given domain. Here, f (X1 = x1,X2 = x2, . . . ,Xn = xn;q)is the joint probability distribution or density of the random variables X1, . . . ,Xnat X1 = x1, . . . ,Xn = xn.

So, the method of maximum likelihood consists of maximizing the likelihoodfunction with respect to q . The value of q that maximizes the likelihood functionis the MLE (maximum likelihood estimate) of q .

Example: The likelihood function in the binomial case:

L(q) =✓

nx

◆q x(1�q)n�x (7.125)

Log likelihood:

`(q) = log✓

nx

◆+ x logq +(n� x) log(1�q) (7.126)

Differentiating and equating to zero to get the maximum:

`0(q) = xq� n� x

1�q= 0 (7.127)

How to get the second term: let u = 1�q .Then, du/dq =�1. Now, y = (n� x) log(1�q) can be rewritten in terms of

u: y = (n� x) log(u). So, dy/du = n�xu .

Now, by the chain rule, dy/dq = dy/du⇥du/dq = n�xu ⇥ (�1) =� n�x

1�q .Rearranging terms, we get:xq � n�x

1�q = 0 , xq = n�x

1�q , q = xn

7.5.0.1 Finding maximum likelihood estimates for different distributions

7.5.0.1.1 Example 1 Let Xi, i= 1, . . . ,n be a random variable with PDF f (x;s)=1

2s exp(� |x|s ). Find s , the MLE of s .

L(s) = ’ f (xi;s) =1

(2s)n exp(� | xi |s

) (7.128)

`(x;s) = � log2� logs � | xi |

s

�(7.129)

Differentiating and equating to zero to find maximum:

`0(s) = � 1

s+

| xi |s2

�=� n

s+

| xi |s2 = 0 (7.130)

Page 107: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

7.5. APPLICATION OF DIFFERENTIATION: METHOD OF MAXIMUM LIKELIHOOD ESTIMATION107

Rearranging the above, the MLE for s is:

s =Â | xi |

n(7.131)

7.5.0.1.2 Exponentialf (x;l ) = l exp(�lx) (7.132)

Log likelihood:

`= n logl �Âlxi (7.133)

Differentiating and equating to zero:

`0(l ) = nl�Âxi = 0 (7.134)

nl= Âxi (7.135)

I.e.,

1l=

Âxi

n(7.136)

7.5.0.1.3 Poisson

L(µ;x) = ’ exp�µ µxi

xi! (7.137)

= exp�µ µÂxi 1’xi! (7.138)

Log likelihood:

`(µ;x) =�nµ +Âxi log µ � logy! (7.139)

Differentiating and equating to zero:

`0(µ) =�n+ Âxi

µ= 0 (7.140)

Therefore:

l =Âxi

n(7.141)

Page 108: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

108CHAPTER 7. SOME BACKGROUND IN STATISTICS, WITH APPLICATIONS OF MATHEMATICAL METHODS

7.5.0.1.4 Geometricf (x; p) = (1� p)x�1 p (7.142)

L(p) = pn(1� p)Âx�n (7.143)

Log likelihood:

`(p) = n log p+(Âx�n) log(1� p) (7.144)

Differentiating and equating to zero:

`0(p)np� Âx�n

1� p= 0 (7.145)

p =1x

(7.146)

7.5.0.1.5 Normal Let X1, . . . ,Xn constitute a random variable of size n from anormal population with mean µ and variance s2, find joint maximum likelihoodestimates of these two parameters.

L(µ;s2) = ’N(xi; µ,s) (7.147)= ( 1

sp

2p )n exp(� 1

2s2 s(xi �µ)2) (7.148)

(7.149)

Taking logs and differentiating with respect to µ and s , we get:

µ =1n Âxi = x (7.150)

and

s2 =1n Â(xi � x)2 (7.151)

Page 109: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

7.6. APPLICATION OF MATRICES: LEAST SQUARES ESTIMATION 109

7.6 Application of matrices: Least squares estima-tion

[Note: I draw heavily from [1], chapters 1 and 4; [9]; and [2].]

Consider the goal of estimating the intercept and slope b0 and b1 (which areunknown population parameters) from a sample:

Yi = b0 +b1Xi + ei (7.152)

Let’s call the estimates of these parameters b0 and b1; Y is the predicted valueof the dependent variable.

Yi = b0 + b1Xi (7.153)

We want to find those beta-hats where the sum of squares of deviation areminimized. I.e., squaring and rearranging (7.152) we get:

S =n

Âi=1

e2i =

n

Âi=1

(Yi �b0 �b1Xi)2 (7.154)

If we differentiate with respect to b0 and then b1, we get:

∂S∂b0

=�2n

Âi=1

(Yi �b0 �b1Xi) (7.155)

and

∂S∂b1

=�2n

Âi=1

Xi(Yi �b0 �b1Xi) (7.156)

this gives us the beta-hats through the two equations:

n

Âi=1

(Yi � b0 � b1Xi) = 0 (7.157)

n

Âi=1

Xi(Yi � b0 � b1Xi) = 0 (7.158)

Rearranging equations (7.157) and (7.158) we get the normal equations:

b0 + b1

n

Âi=1

Xi =n

Âi=1

Yi (7.159)

Page 110: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

110CHAPTER 7. SOME BACKGROUND IN STATISTICS, WITH APPLICATIONS OF MATHEMATICAL METHODS

b0

n

Âi=1

Xi + b1

n

Âi=1

Xi2 =

n

Âi=1

XiYi (7.160)

The above equations (7.159) and (7.160) are used to solve for the beta-hats.Next, we show how to state the normal equations in matrix form.Our linear model equation is a system of i equations. For each i, we can write

the single equation:

Yi = b0 +b1Xi + ei (7.161)

can be expanded to:

Y1 = b0 + X1b1 + e1Y2 = b0 + X2b1 + e2Y3 = b0 + X3b1 + e3Y4 = b0 + X4b1 + e4...

......

...Yn = b0 + Xnb1 + en

(7.162)

And this system of linear equations can be restated in matrix form:

Y = Xb + e (7.163)

whereVector of responses:

Y =

0

BBBBBBB@

Y1Y2Y3Y4...

Yn

1

CCCCCCCA

(7.164)

Page 111: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

7.6. APPLICATION OF MATRICES: LEAST SQUARES ESTIMATION 111

Design Matrix:

X =

0

BBBBBBB@

1 X11 X21 X31 X4...

...1 Xn

1

CCCCCCCA

(7.165)

Vector of parameters:

b =

✓b0b1

◆(7.166)

andVector of error terms:

e =

0

BBBBBBB@

e1e2e3e4...

en

1

CCCCCCCA

(7.167)

We could write the whole equation as:0

BBBBBBB@

Y1Y2Y3Y4...

Yn

1

CCCCCCCA

=

0

BBBBBBB@

1 X11 X21 X31 X4...

...1 Xn

1

CCCCCCCA

⇥✓

b1b2

◆+

0

BBBBBBB@

e1e2e3e4...

en

1

CCCCCCCA

(7.168)

Now, we want to minimize the square of the error, as we did earlier. We can dothis compactly using the matrix notation. Note that if we want to sum the squaredvalues of a vector or numbers, we can either do it like this:

> (epsilon<-rnorm(10))

Page 112: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

112CHAPTER 7. SOME BACKGROUND IN STATISTICS, WITH APPLICATIONS OF MATHEMATICAL METHODS

[1] -0.001745305 -0.512171491 -0.845365230[4] -0.492596106 -1.911414233 -0.261457661[7] 1.504620972 1.510807024 1.551267159[10] 0.474879697

> (epsilon.squared<-epsilon^2)

[1] 3.046089e-06 2.623196e-01 7.146424e-01[4] 2.426509e-01 3.653504e+00 6.836011e-02[7] 2.263884e+00 2.282538e+00 2.406430e+00[10] 2.255107e-01

> sum(epsilon.squared)

[1] 12.11984

>

or we can use matrix multiplication:

> (t(epsilon)%*%epsilon)

[,1][1,] 12.11984

>

We can apply this fact (that we can do all the computations we did above byhand using matrix multiplication) to state our least squares estimation problemby multiplying each side of the equation with its transpose (this is equivalent totaking the square):

S =n

Âi=1

e2i = e 0e = (Y�Xb )0(Y�Xb ) (7.169)

Now, as we did earlier, we take the derivative with respect to the vector b , andwe get:

dSdb

=�2X 0(Y �Xb ) (7.170)

Set this to 0 and solve for b :

�2X 0(Y �Xb ) = 0 (7.171)

Page 113: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

7.6. APPLICATION OF MATRICES: LEAST SQUARES ESTIMATION 113

Rearranging this equation gives us the normal equations we saw earlier, exceptthat it’s in matrix form:

X 0Y = X 0Xb (7.172)

Here, we use the fact that multiplying a matrix by its inverse gives the identitymatrix. This fact about inverses allows us to solve the equation.We just premulti-ply by the inverse of X 0X (written (X 0X)�1) on both sides:

(X 0X)�1X 0Y = (X 0X)�1X 0Xb (7.173)

which gives us:

b = (X 0X)�1X 0Y (7.174)

Example:

> beauty<-read.table("data/beauty.txt",header=TRUE)> head(beauty)

beauty evaluation1 0.2015666 4.32 -0.8260813 4.53 -0.6603327 3.74 -0.7663125 4.35 1.4214450 4.46 0.5002196 4.2

Fit a linear model:

> fm<-lm(evaluation~beauty,beauty)> round(summary(fm)$coefficients,5)

Estimate Std. Error t value(Intercept) 4.01002 0.02551 157.20522beauty 0.13300 0.03218 4.13337

Pr(>|t|)(Intercept) 0e+00beauty 4e-05

Page 114: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

114CHAPTER 7. SOME BACKGROUND IN STATISTICS, WITH APPLICATIONS OF MATHEMATICAL METHODS

> with(beauty,plot(evaluation~beauty))> abline(fm)

−1.5 −1.0 −0.5 0.0 0.5 1.0 1.5 2.0

2.0

2.5

3.0

3.5

4.0

4.5

5.0

beauty

evaluation

> X<-model.matrix(fm)> head(X)

(Intercept) beauty1 1 0.20156662 1 -0.82608133 1 -0.66033274 1 -0.76631255 1 1.42144506 1 0.5002196

> Y<-beauty$evaluation

Use equation 7.174 to find the intercept and slope:

Page 115: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

7.6. APPLICATION OF MATRICES: LEAST SQUARES ESTIMATION 115

> solve(t(X)%*%X)%*%t(X)%*%Y

[,1](Intercept) 4.0100227beauty 0.1330014

Compare with R output:

> coef(fm)

(Intercept) beauty4.0100227 0.1330014

Page 116: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

116CHAPTER 7. SOME BACKGROUND IN STATISTICS, WITH APPLICATIONS OF MATHEMATICAL METHODS

Page 117: Foundations of Mathematics - Department Linguistikvasishth/pdfs/FoundationsMathematics.pdf · 5.1.1 Basic operations .....31 5.1.2 Diagonal matrix and identity matrix ... foundational

Bibliography

[1] N.R. Draper and H. Smith. Applied Regression Analysis. Wiley, New York,1998.

[2] A. Gelman and J. Hill. Data analysis using regression and multi-level/hierarchical models. Cambridge University Press, Cambridge, UK,2007.

[3] J. Gilbert and C.R. Jordan. Guide to mathematical methods. Macmillan,2002.

[4] C.M. Grinstead and J.L. Snell. Introduction to probability. American Math-ematical Society, 1997.

[5] D.W. Jordan and P. Smith. Mathematical Techniques: An Introduction forthe Engineering, Physical, and Mathematical Sciences. Oxford UniversityPress, 4 edition, 2008.

[6] G. Jay Kerns. Introduction to Probability and Statistics Using R. 2010.

[7] Sheldon Ross. A first course in probability. Pearson Education, 2002.

[8] S.L. Salas, E. Hille, and G.J. Etgen. Calculus: One and several variables.Wiley, 2003.

[9] A. Sen and M. Srivastava. Regression Analysis: Theory, Methods and Ap-plications. Springer, New York, 1990.

[10] M. Spivak. Calculus. Cambridge, 2010.

117