lecture 3 matrix algebra

21
Lecture 3 Matrix algebra Species Taxon Guild M ean length (mm) Site 1 Site 2 Site 3 Site 4 Nanoptilium kunzei (H eer,1841) Ptiliidae N ecrophagous 0.60 0 0 0 0 A crotrichis dispar (M atthew s,1865) Ptiliidae N ecrophagous 0.65 13 0 4 7 A crotrichis silvatica R osskothen,1935 Ptiliidae N ecrophagous 0.80 16 0 2 0 A crotrichis rugulosa R osskothen,1935 Ptiliidae N ecrophagous 0.90 0 0 1 0 A crotrichis grandicollis (Mannerheim,1844) Ptiliidae N ecrophagous 0.95 1 0 0 1 A crotrichis fratercula (M atthew s,1878) Ptiliidae N ecrophagous 1.00 0 1 0 0 C arcinops pumilio (Erichson,1834) H isteridae Predator 2.15 1 0 0 0 S aprinus aeneus (Fabricius,1775) H isteridae Predator 3.00 13 23 4 9 G nathoncus nannetensis (Marseul,1862) H isteridae Predator 3.10 0 0 0 2 Margarinotus carbonarius (Hoffmann,1803) H isteridae Predator 3.60 0 5 0 0 R ugilus erichsonii (Fauvel,1867) Staphylinidae Predator 3.75 8 0 5 0 Margarinotus ventralis (Marseul,1854) H isteridae Predator 4.00 3 2 6 1 S aprinus planiusculus M otschulsky,1849 H isteridae Predator 4.45 0 5 0 0 Margarinotus merdarius (Hoffmann,1803) H isteridae Predator 4.50 5 0 6 0 A vector can be interpreted as a file of data A matrix is a collection of vectors and can be interpreted as a data base The red matrix contain three column vectors Handling biological data is most easily done with a matrix approach. An Excel worksheet is a matrix.

Upload: benny

Post on 24-Feb-2016

61 views

Category:

Documents


0 download

DESCRIPTION

Lecture 3 Matrix algebra. A vector can be interpreted as a file of data. A matrix is a collection of vectors and can be interpreted as a data base. The red matrix contain three column vectors. Handling biological data is most easily done with a matrix approach . - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Lecture 3 Matrix  algebra

Lecture 3Matrix algebra

Species Taxon GuildMean length (mm)

Site 1 Site 2 Site 3 Site 4

Nanoptilium kunzei (Heer, 1841) Ptiliidae Necrophagous 0.60 0 0 0 0Acrotrichis dispar (Matthews, 1865) Ptiliidae Necrophagous 0.65 13 0 4 7Acrotrichis silvatica Rosskothen, 1935 Ptiliidae Necrophagous 0.80 16 0 2 0Acrotrichis rugulosa Rosskothen, 1935 Ptiliidae Necrophagous 0.90 0 0 1 0Acrotrichis grandicollis (Mannerheim, 1844) Ptiliidae Necrophagous 0.95 1 0 0 1Acrotrichis fratercula (Matthews, 1878) Ptiliidae Necrophagous 1.00 0 1 0 0Carcinops pumilio (Erichson, 1834) Histeridae Predator 2.15 1 0 0 0Saprinus aeneus (Fabricius, 1775) Histeridae Predator 3.00 13 23 4 9Gnathoncus nannetensis (Marseul, 1862) Histeridae Predator 3.10 0 0 0 2Margarinotus carbonarius (Hoffmann, 1803) Histeridae Predator 3.60 0 5 0 0Rugilus erichsonii (Fauvel, 1867) Staphylinidae Predator 3.75 8 0 5 0Margarinotus ventralis (Marseul, 1854) Histeridae Predator 4.00 3 2 6 1Saprinus planiusculus Motschulsky, 1849 Histeridae Predator 4.45 0 5 0 0Margarinotus merdarius (Hoffmann, 1803) Histeridae Predator 4.50 5 0 6 0

A vector can be interpreted as a

file of data

A matrix is a collection of

vectors and can be interpreted as a data base

The red matrix contain three

column vectors

Handling biological data is most easily done with a matrix approach.An Excel worksheet is a matrix.

Page 2: Lecture 3 Matrix  algebra

A general structure of databases

11 1n

m1 mn

a aA

a a

11 12 13

21 22 23

31 32 33

a a aV a a a

a a a

1

2

3

4

aa

Vaa

1 2 3 4V a a a a

The first subscript denotes rows, the second columns.n and m define the dimension of a matrix. A has m rows and n columns.

Two matrices are equal if they have the same dimension and all corresponding values are identical.

Column vector

Row vector

11 12 13

21 22 23

31 32 33

a a aV a a a

a a a

Page 3: Lecture 3 Matrix  algebra

Solving systems of linear equations

Takakazu Shinsuke Seki (1642-1708)Determinants to solve linear equations

Gottfried Wilhelm Leibniz(1646-1716)Determinants to solve linear equations

Arthur Cayley(1821-1895)Formal matrix algebra

The Nine Chapters on the Mathematical Art.(1000BC-100AD). Systems of linear equations, Gaussian elimination

Matrix approaches

Johann Carl Friedrich Gauss(1777 – 1855)Gaussian elimination, inverse

Olga Taussky-Todd(1906-1995)Finite value matrices

Page 4: Lecture 3 Matrix  algebra

1234876565434321

A

In biology and statistics are square matrices An,n of particular importance

1864875365424321

A

The symmetric matrix is a matrix where An,m = A m,n.

1864075300420001

A

1000870065404321

A

Lower and upper triangular matrices

Some elementary types of matrices

1000070000400001

A

The diagonal matrix is a square and symmetrical.

1000010000100001

A

Unit matrix I 3Λ is a matrix with one row and one column. It is a scalar (ordinary number).

Page 5: Lecture 3 Matrix  algebra

Matrix operations

1 2 3 2 4 0 2 8 1 5 14 42 2 4 1 2 0 7 5 5 10 9 9

A3 5 7 6 9 1 0 0 1 9 14 93 1 0 1 1 4 5 6 1 9 8 5

Addition and Subtraction

Addition and subtraction are only defined for matrices with identical dimensions

nmnmnn

mm

baba

baba

..............................

......

11

111111

BA

S-product1 2 3 1 2 3 1 2 3 3 6 9 1 2 3 3 1 3 2 3 32 2 4 2 2 4 2 2 4 6 6 12 2 2 4 3 2 3 2 3 4

A 33 5 7 3 5 7 3 5 7 9 15 21 3 5 7 3 3 3 5 3 73 1 0 3 1 0 3 1 0 9 3 0 3 1 0 3 3 3 1 3 0

A B B A 1B AA B B AA (B C) (A B) CA A(A B) A BA( ) A A

BB

nmn

m

bb

bb

..............................

......

1

111

Page 6: Lecture 3 Matrix  algebra

The inner or dot or scalar product

Assume you have production data (in tons) of winter wheat (15 t), summer wheat (20 t), and barley (30 t). In the next year weather condition reduced the winter wheat production

by 20%, the summer wheat production by 10% and the barley production by 30%. How many tons do you get the next year?

(15*0.8 + 20* 0.9 + 30 * 0.7) t = 51 t.

0.8

P 15 20 30 0.9 15*0.8 20*0.9 30*0.7 510.7

1 n

1 n i ii 1

n

bA B a ... a ... a b scalar

b

The dot product is only defined for matrices, where the number of columns in the first matrix equals the number of rows in the second matrix.

Page 7: Lecture 3 Matrix  algebra

We add another year and ask how many cereals we get if the second year is good and gives 10 % more of winter wheat, 20 % more of summer wheat and 25 % more of barley. For

both years we start counting with the original data and get a vector with one row that is the result of a two step process

0.8 1.1

P 15 20 30 0.9 1.2 15*0.8 20*0.9 30*0.7 15*1.1 20*1.2 30*1.25 51 780.7 1.25

m m

1i i1 1i iki 1 i 111 1m 11 1k 1 1 1 k

m mn1 nm m1 mk m 1 m k

ni i1 ni iki 1 i 1

a b ... a ba ... a b ... b A B ... A B

A B ... ... ... ... ... ... ... ... ... ... ... ...a ... a a ... a A B ... A B

a b ... a b

A B B A(A B) C A (B C) A B C(A B) C A C B C

Page 8: Lecture 3 Matrix  algebra

12 4

23 5

3

2 4

2 4 63 5

2 4 2 4 6 2 2 4 5 2 4 4 6 2 6 4 7 24 32 403 5 5 6 7 3 2 5 5 3 4 5 6 3 6 5 7 31 42 53

The number of columns in the first matrix must equal the number of rows in the second matrix.

ikjkij CBA izyzlmkljkij CZDCBA ...A

2x3 1 2 31 2 1

B AB3x2 1 3 2x2 17 18

2 3 9 124 3

C ABC2x4 2 3 4 5 2x4 106 87 86 175

4 2 1 5 66 51 48 105

D ABCD4x3 1 6 3 2x3 1153 1943 1011

3 2 2 687 1167 5971 3 44 5 1

Page 9: Lecture 3 Matrix  algebra

403920213029

44332112

543212344321

402030392129

514423332421

*43214312

Transpose A’ ot AT

mnn

mT

mnm

n

aa

aa

aa

aa

.....................

...

..................

......

1

111

1

111

39448356.312141459.3171828.21

3456.314159.3981171828.24321 T

BA TT AB

TTT ABBA )(

Page 10: Lecture 3 Matrix  algebra

Matrix add in for Excel:www.digilander.libero.it/foxes/SoftwareDownload.htm

Page 11: Lecture 3 Matrix  algebra

'' AAAA always exists and gives a

symmetric matrix

'' AAAA only if A is square

and symmetric

Some properties of the transpose

Orthogonal matrixA 3 -1 -1

2 2 0.51 -1 2

A' 3 2 1-1 2 -1-1 0.5 2

AA' 11 3.5 23.5 8.25 1

2 1 6

A'A 14 0 00 6 00 0 5.25

If A is orthogonal A’A is diagonal, but AA’ need not to be diagonal

Page 12: Lecture 3 Matrix  algebra

Species wros wron wil ter swi sos mil lipPterostichus nigrita (Paykull) 0 2 61 53 0 18 39 2Platynus assimilis (Paykull) 0 0 1 0 0 9 0 117Amara brunea (Gyllenhal) 1 1 0 0 19 40 0 1Agonum lugens (Duftshmid) 1 1 2 2 0 0 0 0Loricera pilicornis (Fabricius) 0 0 1 0 0 0 3 0Pterostichus vernalis (Panzer) 1 1 21 2 0 1 7 0Amara plebeja (Gyllenhal) 0 0 0 0 1 2 0 4Badister unipustulatus Bonelli 0 0 0 0 4 1 0 3Lasoitrechus discus (Fabricius) 0 0 0 1 0 0 1 0Poecilus cupreus (Linnaeus) 0 0 0 0 0 2 0 0Amara aulica (Panzer) 0 1 0 0 0 0 0 0Anisodatylus binotatus (Fabricius) 0 0 0 0 0 0 2 0Bembidion articulatum (Panzer) 0 0 0 0 0 0 1 0Clivina collaris (Herbst) 0 0 0 0 0 0 2 0

Ground beetles on Mazurian lake islands (Mamry)

Photo Marek Ostrowski

Carabus auratus Carabus problematicus

Page 13: Lecture 3 Matrix  algebra

Species wros wron wil ter swi sos mil lipPterostichus nigrita (Paykull) 0 2 61 53 0 18 39 2Platynus assimilis (Paykull) 0 0 1 0 0 9 0 117Amara brunea (Gyllenhal) 1 1 0 0 19 40 0 1Agonum lugens (Duftshmid) 1 1 2 2 0 0 0 0Loricera pilicornis (Fabricius) 0 0 1 0 0 0 3 0Pterostichus vernalis (Panzer) 1 1 21 2 0 1 7 0Amara plebeja (Gyllenhal) 0 0 0 0 1 2 0 4Badister unipustulatus Bonelli 0 0 0 0 4 1 0 3Lasoitrechus discus (Fabricius) 0 0 0 1 0 0 1 0Poecilus cupreus (Linnaeus) 0 0 0 0 0 2 0 0Amara aulica (Panzer) 0 1 0 0 0 0 0 0Anisodatylus binotatus (Fabricius) 0 0 0 0 0 0 2 0Bembidion articulatum (Panzer) 0 0 0 0 0 0 1 0Clivina collaris (Herbst) 0 0 0 0 0 0 2 0

Panagaeus cruxmajor (Linnaeus) 0 24 0 0 1 0 5 1Poecilus versicolor (Sturm) 0 0 0 0 0 0 0 2Pterostichus gracilis Dejean) 0 0 0 0 0 0 0 0Stenolophus mixtus 0 0 0 1 0 0 0 0Pseudoophonus rufipes (De Geer) 0 0 13 0 0 5 3 2Harpalus latus (Linnaeus) 0 0 0 0 0 3 0 2Agonum duftshmidi Shmidt 0 0 1 0 0 0 0 0Harpalus solitaris Dejean 0 0 0 0 1 0 1 0

Species associations

Page 14: Lecture 3 Matrix  algebra
Page 15: Lecture 3 Matrix  algebra
Page 16: Lecture 3 Matrix  algebra

S

Panagaeus cruxmajor (Linnaeus)

Poecilus versicolor (Sturm)

Pterostichus gracilis Dejean)

Stenolophus mixtus

Pseudoophonus rufipes (De Geer)

Harpalus latus (Linnaeus)

Agonum duftshmidi Shmidt

Harpalus solitaris Dejean

wros 0 0 0 0 0 0 0 0wron 24 0 0 0 0 0 0 0wil 0 0 0 0 13 0 1 0ter 0 0 0 1 0 0 0 0swi 1 0 0 0 0 0 0 1sos 0 0 0 0 5 3 0 0mil 5 0 0 0 3 0 0 1lip 1 2 0 0 2 2 0 0

Species wros wron wil ter swi sos mil lipPterostichus nigrita (Paykull) 0 2 61 53 0 18 39 2Platynus assimilis (Paykull) 0 0 1 0 0 9 0 117Amara brunea (Gyllenhal) 1 1 0 0 19 40 0 1Agonum lugens (Duftshmid) 1 1 2 2 0 0 0 0Loricera pilicornis (Fabricius) 0 0 1 0 0 0 3 0Pterostichus vernalis (Panzer) 1 1 21 2 0 1 7 0Amara plebeja (Gyllenhal) 0 0 0 0 1 2 0 4Badister unipustulatus Bonelli 0 0 0 0 4 1 0 3Lasoitrechus discus (Fabricius) 0 0 0 1 0 0 1 0Poecilus cupreus (Linnaeus) 0 0 0 0 0 2 0 0Amara aulica (Panzer) 0 1 0 0 0 0 0 0Anisodatylus binotatus (Fabricius) 0 0 0 0 0 0 2 0Bembidion articulatum (Panzer) 0 0 0 0 0 0 1 0Clivina collaris (Herbst) 0 0 0 0 0 0 2 0

Species

Panagaeus cruxmajor (Linnaeus)

Poecilus versicolor (Sturm)

Pterostichus gracilis Dejean)

Stenolophus mixtus

Pseudoophonus rufipes (De Geer)

Harpalus latus (Linnaeus)

Agonum duftshmidi Shmidt

Harpalus solitaris Dejean

Pterostichus nigrita (Paykull) 245 4 0 53 1004 58 61 39Platynus assimilis (Paykull) 117 234 0 0 292 261 1 0Amara brunea (Gyllenhal) 44 2 0 0 202 122 0 19Agonum lugens (Duftshmid) 24 0 0 2 26 0 2 0Loricera pilicornis (Fabricius) 15 0 0 0 22 0 1 3Pterostichus vernalis (Panzer) 59 0 0 2 299 3 21 7Amara plebeja (Gyllenhal) 5 8 0 0 18 14 0 1Badister unipustulatus Bonelli 7 6 0 0 11 9 0 4Lasoitrechus discus (Fabricius) 5 0 0 1 3 0 0 1Poecilus cupreus (Linnaeus) 0 0 0 0 10 6 0 0Amara aulica (Panzer) 24 0 0 0 0 0 0 0Anisodatylus binotatus (Fabricius) 10 0 0 0 6 0 0 2Bembidion articulatum (Panzer) 5 0 0 0 3 0 0 1Clivina collaris (Herbst) 10 0 0 0 6 0 0 2

Page 17: Lecture 3 Matrix  algebra

Species wros wron wil ter swi sos mil lip kor hel guc gil ful dab 3pog 2pog 1pogPterostichus nigrita (Paykull) 0 0.79 0.01 0.14 0 0.15 0.37 0.14 0 0 0.45 0.51 0.56 0.01 0.28 0.74 0.18Platynus assimilis (Paykull) 0 0 0.83 0 0 0.53 0 0.86 0.76 0.59 0.62 0.2 0.03 0.85 0.37 0.83 0Amara brunea (Gyllenhal) 0.59 0.97 0 0 0.11 0.02 0 0.47 0 0.87 0.54 0 0.39 0.47 0 0 0Agonum lugens (Duftshmid) 0.02 0.06 0.18 0.74 0 0 0 0 0 0 0 1 0 0.37 0 0 0.89Loricera pilicornis (Fabricius) 0 0 0.08 0 0 0 0.97 0 0 0 0 0.27 0.56 0.89 0 0.46 0Pterostichus vernalis (Panzer) 0.1 0.59 0.88 0.87 0 0.4 1 0 0 0 0 0 0 0 0 0 0Amara plebeja (Gyllenhal) 0 0 0 0 0.19 0.09 0 0.86 0 0 0 0.19 0 0.37 0 0 0Badister unipustulatus Bonelli 0 0 0 0 0.4 0.03 0 0.58 0 0 0 0.34 0 0 0 0 0Lasoitrechus discus (Fabricius) 0 0 0 0.02 0 0 0 0 0 0 0 0 0 0 0 0 0Poecilus cupreus (Linnaeus) 0 0 0 0 0 0.42 0 0 0.12 0 0 0 0 0 0 0 0Amara aulica (Panzer) 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.59 0 0Anisodatylus binotatus (Fabricius) 0 0 0 0 0 0 0.8 0 0 0 0 0 0 0 0 0 0Bembidion articulatum (Panzer) 0 0 0 0 0 0 0.72 0 0 0 0 0 0 0 0 0 0Clivina collaris (Herbst) 0 0 0 0 0 0 0.65 0 0 0 0 0 0 0 0 0 0Species wros wron wil ter swi sos mil lip kor hel guc gil ful dab 3pog 2pog 1pogPanagaeus cruxmajor (Linnaeus) 0 0 0 0 0 0 0 0.7 0 0 0 0 0 0 0 0 0Poecilus versicolor (Sturm) 0 0 0 0 0 0 0 0.38 0 0 0 0 0 0 0 0 0Pterostichus gracilis Dejean) 0 0 0 0 0 0 0 0 0 0 0 0.38 0 0 0 0 0Stenolophus mixtus 0 0 0 0.11 0 0 0 0 0 0 0 0 0 0 0 0 0Pseudoophonus rufipes (De Geer) 0 0 0.22 0 0 0.83 0.98 0.66 0.58 0.04 0.32 0.51 0.19 0.62 0.17 0.54 0.53Harpalus latus (Linnaeus) 0 0 0 0 0 0.29 0 0.64 0.35 0 0 0.18 0.15 0 0.17 0.25 0Agonum duftshmidi Shmidt 0 0 0.17 0 0 0 0 0 0 0 0 0 0 0 0.22 0 0.17Harpalus solitaris Dejean 0 0 0 0 0 0 0 0 0 0 0 0.81 0.85 0 0 0 0

Probabilities of co-occurrence

Page 18: Lecture 3 Matrix  algebra

Species Panagaeus cruxmajor (Linnaeus)Poecilus versicolor (Sturm)Pterostichus gracilis Dejean)Stenolophus mixtusPseudoophonus rufipes (De Geer)Harpalus latus (Linnaeus)Agonum duftshmidi ShmidtHarpalus solitaris DejeanPterostichus nigrita (Paykull)0.034035 0.036504 0.213372 0.347488 4.640972 2.625121 0.682791 0.328616Platynus assimilis (Paykull)0.35977 0.385866 0.047028 0 2.791692 2.228522 0.572894 0.16836Amara brunea (Gyllenhal)0.22055 0.236548 0 0 2.735377 1.078382 0 0.005715Agonum lugens (Duftshmid)0 0 0.149993 0.477588 2.060951 0.613648 0.432521 0.206119Loricera pilicornis (Fabricius)0 0 0.062924 0 2.527301 1.257689 0.254665 0.235746Pterostichus vernalis (Panzer)0 0 0 0.287552 1.234233 0.455731 0.020836 0Amara plebeja (Gyllenhal)0.126953 0.136162 0.145696 0 1.244267 0.955163 0 0.200214Badister unipustulatus Bonelli0.209502 0.224699 0.059252 0 0.895534 1.127406 0 0.081424Lasoitrechus discus (Fabricius)0 0 0 0.158252 0.18667 0 0 0Poecilus cupreus (Linnaeus)0 0 0 0 0.804519 0.570117 0 0Amara aulica (Panzer)0 0 0 0 0.015829 0.016889 0.004067 0Anisodatylus binotatus (Fabricius)0 0 0 0 0.006664 0 0 0Bembidion articulatum (Panzer)0 0 0 0 0.333915 0 0 0Clivina collaris (Herbst)0 0 0 0 0.082518 0 0 0

T21PPR

The entries of the matrix give the sum of probabilities that two species meet on any of the islands.

15

1

)(i

PanagaeussPterosticu PPPanagaeususPterostichR

Page 19: Lecture 3 Matrix  algebra

Assume you are studying a contagious disease. You identified as small group of 4 persons infected by the disease.

These 4 persons contacted in a given time with another group of 5 persons. The latter 5 persons had contact with other persons, say with 6, and so on. How often did a person

of group C indirectly contact with a person of group A?

00101000100100101101

A

A1 2 3 4

B

12345

000100001011000110000001010001

B

B1 2 3 4 5

C

123456

001000101010101000101111

00101000100100101101

000100001011000110000001010001

ABC

A1 2 3 4

C

123456

We eliminate group B and leave the first and last group.

No. 1 of group C indirectly contacted with all members of group A.No. 2 of group A indirectly contacted with all six persons of group C.

Page 20: Lecture 3 Matrix  algebra

Instead of contact we use probabilities of being infected.

B 1 2 3 41 0.3 0 0.2 0.22 0 0.3 0 03 0.3 0 0 14 0 0 0 15 0 0.3 0 0

C 1 2 3 4 51 0.3 0 0 0 0.22 0 0.3 0 0 03 0 0 0 0.1 0.24 0 0 0 0.1 0.25 0 0.3 0 0 06 0 0.3 0 0 0

C 1 2 3 4 Sum1 0.09 0.06 0.06 0.06 0.272 0 0.09 0 0 0.093 0 0.06 0 0.1 0.164 0 0.06 0 0.1 0.165 0 0.09 0 0 0.096 0 0.09 0 0 0.09

A

B

A

ABC

Person 1 of group C has the highest probability of being infected.

Page 21: Lecture 3 Matrix  algebra

Home work and literatureRefresh:

• Vectors• Vector operations (sum, S-product, scalar product)• Scalar product of orthogonal vectors• Distance metrics (Euclidean, Manhattan, Minkowski)• Cartesian system, orthogonal vectors• Matrix• Types of matrices• Basic matrix operations (sum, S-product, dot product)

Prepare to the next lecture:

• Linear equations• Inverse• Stochiometric equations

Literature:

Mathe-onlineStoichiometric equations: http://sciencesoft.at/equation/index?lang=enStoichiometry: http://en.wikipedia.org/wiki/Stoichiometry