Lecture 5: Linear Algebra

Slides:



Advertisements
Similar presentations
Matrices A matrix is a rectangular array of quantities (numbers, expressions or function), arranged in m rows and n columns x 3y.
Advertisements

Matrices & Systems of Linear Equations
3_3 An Useful Overview of Matrix Algebra
ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 12 System of Linear Equations.
Chapter 2 Matrices Definition of a matrix.
Review of Probability and Statistics
Part 3 Chapter 8 Linear Algebraic Equations and Matrices PowerPoints organized by Dr. Michael R. Gustafson II, Duke University All images copyright © The.
Modern Navigation Thomas Herring
Matrix Approach to Simple Linear Regression KNNL – Chapter 5.
Intro to Matrices Don’t be scared….
Row 1 Row 2 Row 3 Row m Column 1Column 2Column 3 Column 4.
Compiled By Raj G. Tiwari
ECON 1150 Matrix Operations Special Matrices
Matrix Algebra. Quick Review Quick Review Solutions.
Review of Matrices Or A Fast Introduction.
Overview Definitions Basic matrix operations (+, -, x) Determinants and inverses.
Copyright © 2011 Pearson, Inc. 7.2 Matrix Algebra.
10.4 Matrix Algebra 1.Matrix Notation 2.Sum/Difference of 2 matrices 3.Scalar multiple 4.Product of 2 matrices 5.Identity Matrix 6.Inverse of a matrix.
Matrix Algebra and Regression a matrix is a rectangular array of elements m=#rows, n=#columns  m x n a single value is called a ‘scalar’ a single row.
BIOL 582 Supplemental Material Matrices, Matrix calculations, GLM using matrix algebra.
A Review of Some Fundamental Mathematical and Statistical Concepts UnB Mestrado em Ciências Contábeis Prof. Otávio Medeiros, MSc, PhD.
Fundamentals of Engineering Analysis
Chapter 6 Systems of Linear Equations and Matrices Sections 6.3 – 6.5.
Special Topic: Matrix Algebra and the ANOVA Matrix properties Types of matrices Matrix operations Matrix algebra in Excel Regression using matrices ANOVA.
MT411 Robotic Engineering Asian Institution of Technology (AIT) Chapter 1 Introduction to Matrix Narong Aphiratsakun, D.Eng.
MATRIX A set of numbers arranged in rows and columns enclosed in round or square brackets is called a matrix. The order of a matrix gives the number of.
Use Inverse Matrices to Solve Linear Systems Objectives 1.To find the inverse of a square matrix 2.To solve a matrix equation using inverses 3.To solve.
Matrices. Variety of engineering problems lead to the need to solve systems of linear equations matrixcolumn vectors.
13.3 Product of a Scalar and a Matrix.  In matrix algebra, a real number is often called a.  To multiply a matrix by a scalar, you multiply each entry.
10.4 Matrix Algebra. 1. Matrix Notation A matrix is an array of numbers. Definition Definition: The Dimension of a matrix is m x n “m by n” where m =
MATRICES A rectangular arrangement of elements is called matrix. Types of matrices: Null matrix: A matrix whose all elements are zero is called a null.
Statistical Genomics Zhiwu Zhang Washington State University Lecture 5: Linear Algebra.
Statistical Genomics Zhiwu Zhang Washington State University Lecture 4: Statistical inference.
College Algebra Chapter 6 Matrices and Determinants and Applications
MTH108 Business Math I Lecture 20.
Introduction to Vectors and Matrices
Lecture 3: Distribution of random variables
Linear Algebra Review.
Linear Algebraic Equations and Matrices
MATRICES.
Linear Algebra Lecture 2.
Lecture 4: Statistical inference
Lecture 3: Distribution of random variables
Matrices and vector spaces
A.2 Simplifying Simplify means combine Like Terms.
Lecture 3: Distribution of random variables
Linear Algebraic Equations and Matrices
Linear independence and matrix rank
Lecture 5: Linear Algebra
Section 7.4 Matrix Algebra.
Lecture 5: Linear Algebra
Matrix Algebra.
MATRICES MATRIX OPERATIONS.
Matrices Definition: A matrix is a rectangular array of numbers or symbolic elements In many applications, the rows of a matrix will represent individuals.
Lecture 3: Distribution of random variables
Use Inverse Matrices to Solve Linear Systems
Solving Linear Systems Using Inverse Matrices
MATRICES MATRIX OPERATIONS.
Lecture 11 Matrices and Linear Algebra with MATLAB
Unit 3: Matrices
Matrix Algebra and Random Vectors
Section 11.4 Matrix Algebra
MATRICES Operations with Matrices Properties of Matrix Operations
Matrix Algebra.
Introduction to Vectors and Matrices
Lecture 8 System of Linear Differential Equations fall semester
Linear Algebra review (optional)
MATRICES MATRIX OPERATIONS.
MATRICES MATRIX OPERATIONS.
Lecture 3: Distribution of random variables
Presentation transcript:

Lecture 5: Linear Algebra Statistical Genomics Lecture 5: Linear Algebra Zhiwu Zhang Washington State University

Administration Homework1, due next Wednesday, Feb 1, 3:10PM

Outline Example of first question on homework1 Expectation and Variance of random variable Expectation and Variance of function of random variable Covariance Matrix and manipulations Special matrices: Identity, symmetric, diagonal, singular, and orthogonal Rank

Question 1 in Homework1 Start from random variables with standard normal distribution, define your own random variable that is function of the normal distributed variables. Name the random variable as your last name and develop a R function to generate the random variable. The input of your R function should include n, which is number variables to be generated, and parameters for the distribution of the random variable you defined. Note: try not to be the same as the known distributions such as Chi-square, F and t.

Example of Chi-square distribution #There is a function in R x=rchisq(n=10000,df=5) #Expectation is df and var=2df par(mfrow=c(2,2),mar = c(3,4,1,1)) plot(x) hist(x) plot(density(x)) plot(ecdf(x)) mean(x) var(x)

Self-defined function of Chi-square rZhang=function(n=10,df=2){ y=replicate(n,{ x=rnorm(df,0,1) y=sum(x^2) }) return(y) } x1=rchisq(n=10000,df=5) x2=rZhang(n=10000,df=5) plot(density(x1),col="blue") lines(density(x2),col="red")

Expectation=Mean when sample size goes to infinity par(mfrow=c(3,1),mar = c(3,4,1,1)) x=rchisq(n=10,df=5) hist(x) abline(v=mean(x), col = "red") x=rchisq(n=100,df=5) x=rchisq(n=10000,df=5)

Variance Range Average deviation from mean, but it is always zero Average squared deviation from mean: Variance Square root of variance = standard deviation n=100 x=rnorm(100,100,5) c(min(x),max(x)) sum(x-mean(x))/(n-1) sum((x-mean(x))^2)/ sqrt(sum((x-mean(x))^2)/(n-1))

Expectation and variance of linear function of random variables df=10 x=rchisq(n,df) mean(x) var(x) y=5*x mean(y) var(y) z=5+x mean(z) var(z) y=ax, E(y)=aE(x), Var(y)=a^2*Var(x) y=x+a, E(y)=E(x)+a, Var(y)=Var(x)

Covariance n=10000 x=rpois(n, 100) y=rchisq(n,5) z=rt(n,100) par(mfrow=c(3,1),mar = c(3,4,1,1)) plot(x,y) plot(x,z) plot(y,z) var(x) var(y) var(z) cov(x,y) cov(x,z) cov(y,z)

Covariance n=10000 a=rnorm(n,100,5) x=a+rpois(n, 100) y=a+rchisq(n,5) z=a+rt(n,100) par(mfrow=c(3,1),mar = c(3,4,1,1)) plot(x,y) plot(x,z) plot(y,z) var(x) var(y) var(z) cov(x,y) cov(x,z) cov(y,z)

Formula of covariance Cov(x,y)= sum( (x- mean(x)) * (y- mean(y)) )/(n-1) sum((x-mean(x))*(y-mean(y)))/(n-1) sum((x-mean(x))*(z-mean(z)))/(n-1) sum((y-mean(y))*(z-mean(z)))/(n-1)

Calculation in R W=cbind(x,y,z) dim(W) cov(W) var(W)

Element-wise Matrix manipulations Add/ subtraction (dot)product (dot)division a=matrix(seq(10,60,10),2,3) b=matrix(seq(1,6),2,3) a b a+b a-b a*b a/b

Multiplication AS 1 BS 2 MS 3 PhD 4 Salary SQF Mean 20000 1000 Edu 10000 300 Age 20 Mean Education Age 1 30 4 50 Salary SQF 60000 1900 110000 3200 c=matrix(c(1,1,1,4,30,50),2,3) b=matrix(c(1000,300,20,20000,10000,1000),3,2) t=c%*%b

Inverse is for square matrix only IF: 1 … A B = B is inverse of A vice versa Inverse is for square matrix only

Inverse in R: solve() t ti=solve(t) ti ti %*% t t%*%ti

Transpose Transpose c=matrix(c(1,1,1,4,30,50),2,3) c t(c)

Properties of transpose (AT)T=A (A+B)T=AT+BT (AB)T=BTAT (cB)T=cBT , where c is scalar A=matrix(c(1,1,1,4,30,50),2,3) B=matrix(c(1000,300,20,20000,10000,1000),3,2) t(A%*%B) t(B)%*%t(A)

Special matrix Symmetric: A=Transpose(A) Diagonal matrix: all elements are 0 except diagonals Identity: Diagonals=1 and res=0 Orthogonal: A multiply by transpose (A) = Identity Singular: A square matrix does not have a inverse

Rank The size of the largest non-singular sub matrix Full rank matrix: rank=dimension

Highlight Example of first question on homework1 Expectation and Variance of random variable Expectation and Variance of function of random variable Covariance Matrix and manipulations Special matrices: Identity, symmetric, diagonal, singular, and orthogonal Rank