750 likes | 894 Views
Agenda. 1. Tools 2. Matrices 3. Least squares 4. Propagation of variances 5. Geometry. 1. Tools. Excel Matlab Mathcad Labview. 1. Tools. Excel. Spreadsheet Readily available Solver functions. 1. Tools. Matlab. Matrix based Powerful analytical tool Handles transforms well
E N D
Agenda 1. Tools 2. Matrices 3. Least squares 4. Propagation of variances 5. Geometry
1. Tools Excel Matlab Mathcad Labview 1. Tools
Excel • Spreadsheet • Readily available • Solver functions 1. Tools
Matlab • Matrix based • Powerful analytical tool • Handles transforms well • Easy to program 1. Tools
Mathcad • Mathematical tool • Evolving into handling transfer functions • Has special programming language • Documentation closer to real math 1. Tools
Labview • Powerful analysis tool • Uses graphical language to translate concepts into C-code and then execute 1. Tools
2. Matrices (1 of 2) • Addition • Subtraction • Multiplication • Vector, dot product, & outer product • Transpose • Determinant of a 2x2 matrix • Cofactor and adjoint matrices • Determinant • Inverse matrix 2. Matrices
Matrices (2 of 2) • Orthogonal matrix • Hermetian matrix • Unitary matrix 2. Matrices
Addition (1 of 2) C=A+B 1 -1 -1 0 4 2 -1 0 1 2 -2 -1 -2 5 -1 1 0 3 1 -1 0 -2 1 -3 2 0 2 A= B= C= cIJ = aIJ + bIJ 2. Matrices
Addition (2 of 2) Matrix addition using Excel 2. Matrices
Subtraction (1 of 2) C=A-B 1 -1 -1 0 4 2 -1 0 1 0 0 1 -2 -3 -5 3 0 1 1 -1 0 -2 1 -3 2 0 2 A= B= C= cIJ = aIJ - bIJ 2. Matrices
Subtraction (2 of 2) Matrix subtraction using Excel 2. Matrices
Multiplication (1 of 2) C=A*B 1 -1 -1 0 4 2 -1 0 1 1 -5 -3 1 6 1 0 -2 0 1 -1 0 -2 1 -3 2 0 2 A= B= C= cIJ = aI1 * b1J + aI2 * b2J + aI3 * b3J 2. Matrices
Multiplication (2 of 2) Matrix multiplication using Excel 2. Matrices
Transpose (1 of 3) B=AT 1 -1 0 -2 1 -3 2 0 2 1 -2 2 -1 1 0 0 -3 2 A= B= bIJ = aJI 2. Matrices
Transpose (2 of 3) Matrix transpose using Excel 2. Matrices
Transpose (3 of 3) • (AB)T = BT AT 1 -1 0 -2 1 -3 2 0 2 1 -1 -1 0 4 2 -1 0 1 1 1 0 -5 6 -2 -3 1 0 A= B= (AB)T = 1 0 -1 -1 4 0 -1 2 1 1 -2 2 -1 1 0 0 -3 2 1 1 0 -5 6 -2 -3 1 0 AT = BT = BTAT = 2. Matrices
Vector, dot & outer products (1 of 2) • A vector v is an N x 1 matrix • Dot product = inner product = vT x v = a scalar • Outer product = v x vT = N x N matrix 2. Matrices
Vector, dot & outer products (2 of 2) Matrix inner and outer products using Excel 2. Matrices
Determinant of a 2x2 matrix 1 -1 -2 1 B = = -1 2x2 determinant = b11 * b22 - bI2 * b21 2. Matrices
Cofactor and adjoint matrices 1 -1 0 -2 1 -3 2 0 2 A= 1 -3 0 2 -2 -3 2 2 -2 1 2 0 - 2 -2 -2 2 2 -2 3 3 -1 -1 0 0 2 1 0 2 2 1 -1 2 0 B = cofactor = - = - -1 0 0 -3 1 0 -2 -3 1 -1 -2 1 - 2 2 3 -2 2 3 -2 -2 -1 C=BT = adjoint= 2. Matrices
Determinant 1 -1 0 -2 1 -3 2 0 2 determinant of A = =4 1 -1 0 2 -2 -2 = 4 The determinant of A = dot product of any row in A times the corresponding column in the adjoint matrix = dot product of any row (or column) in A times the corresponding row (or column) in the cofactor matrix 2. Matrices
Inverse matrix (1 of 3) 0.5 0.5 0.75 -0.5 0.5 0.75 -0.5 -0.5 -0.25 B = A-1 =adjoint(A)/determinant(A) = 1 -1 0 -2 1 -3 2 0 2 0.5 0.5 0.75 -0.5 0.5 0.75 -0.5 -0.5 -0.25 1 0 0 0 1 0 0 0 1 = Inverse 2. Matrices
Inverse matrix (2 of 3) Matrix inverse using Excel 2. Matrices
Inverse matrix (3 of 3) 1 -1 0 -2 1 -3 2 0 2 1 -1 -1 0 4 2 -1 0 1 0.25 0.75 1.625 0 0 -0.5 -0.25 0.35 1.375 • (AB)-1 = B-1 A-1 A= B= (AB)-1 = 0.5 0.5 0.75 -0.5 0.5 0.75 -0.5 -0.5 -0.25 A-1 = 0.25 0.75 1.625 0 0 -0.5 -0.25 0.35 1.375 B-1A-1 = 2 0.5 1 -1 0 -1 2 0.5 2 B-1 = Inverse of a product 2. Matrices
Orthogonal matrix • An orthogonal matrix is a matrix whose inverse is equal to its transpose. 1 0 0 0 cos sin 0 -sin cos 1 0 0 0 cos -sin 0 sin cos 1 0 0 0 1 0 0 0 1 = 2. Matrices
Hermetian matrix (1 of 3) • A Hermetian matrix is a matrix that is equal to its own Hermetian transpose • A = AH • The Hermetian transpose of A is the complex conjugate transpose of A • AH = AT Hermetian matrix 2. Matrices
Hermetian matrix (2 of 3) 1 1-I 2 1+I 3 i 2 -i 0 A = 1 1+I 2 1-I 3 - i 2 +i 0 AT = 1 1-I 2 1+I 3 i 2 -i 0 AT = = A Example 2. Matrices
Hermetian matrix (3 of 3) Hermetian matrix using Excel 2. Matrices
Unitary matrix • A matrix is unitary if its inverse equals its Hermetian transpose • U-1 = UH • DFT and inverse DFT are unitary matrices 2. Matrices
3. Least squares • Example 1 • Example 2 3. Least squares
Example 1 (1 of 9) x + 2y + 3z = 14 -2x + + z = 1 2x + y = 4 1 2 3 -2 0 1 2 1 0 -1 3 2 2 -6 -7 -2 3 4 14 1 4 -1/3 A = A-1 = b = x y z 1 2 3 = A-1 b = Solve 3 equations and 3 unknowns 3. Least squares
Example 1 (2 of 9) x + 2y + 3z = 14 -2x + + z = 1 2x + y = 4 3x + y - z = 2 x y z 1 2 3 = x + 2y + 3z = 13 -2x + + z = 1 2x + y = 4 3x + y - z = 3 x y z = ? What happens if we have 4 equations and 3 unknowns 3. Least squares
Example 1 (3 of 9) e1 = x + 2y + 3z - 13 e2 = -2x + + z - 1 e3 = 2x + y - 4 e4 = 3x + y - z - 3 Minimize J = (e12 + e22 +e32 +e42) Minimize the sum of squares 3. Least squares
Example 1 (4 of 9) Solve using Solver in Excel 3. Least squares
Example 1 (5 of 9) e1 = x + 2y + 3z - 13 e2 = -2x + + z - 1 e3 = 2x + y - 4 e4 = 3x + y - z - 3 1 2 3 -2 0 1 2 1 0 3 1 1 13 1 4 3 b = A = x y z 0.46 3.37 1.91 ATA s = AT b s = [ATA]-1 AT b = = Solve using matrices 3. Least squares
Example 1 (6 of 9) a1x a1y a1z a2x a2y a2z a3x a3y a3z a4x a4y a4z b1 b2 b3 b4 a1x a2x a3x a4x a1y a2y a3y a4y a1z a2z a3z a4z A = AT = b = a1x a2x a3x a4x a1y a2y a3y a4y a1z a2z a3z a4z a1x a1y a1z a2x a2y a2z a3x a3y a3z a4x a4y a4z AT A = akx akx aky akx akz akx akx aky aky aky akz aky akx akz aky akz akz akz = Express matrix solution in more general terms 3. Least squares
Example 1 (7 of 9) akxbk akxbk akzbk AT b = Express matrix solution in more general terms (cont) 3. Least squares
Example 1 (8 of 9) J = [a1xx + a1yy + a1zz - b1]2 + [a2xx + a2yy + a2zz - b2]2 + [a3xx + a3yy + a3zz - b3]2 + [a4xx + a4yy + a4zz - b4]2 J/ x = 2[a1xa1xx + a1ya1xy + a1za1xz - a1xb1] + [a2xa2xx + a2ya2xy + a2za2xz - a2xb2] + [a3xa3xx + a3ya3xy + a3za3xz - a3xb3] + [a4xa4xx + a4ya4xy + a4za4xz - a4xb4] 2[ akx akx x aky akx y akz akxz - akxbk ] = 0 Minimize by calculus 3. Least squares
Example 1 (9 of 9) akx akx x aky akx y akz akxz - akxbk = 0 akx aky x aky aky y akz akyz - akybk = 0 akx akz x aky akz y akz akzz - akzbz = 0 akx akx aky akx akz akx akx aky aky aky akz aky akx akz aky akz akz akz akxbk akybk akzbk x y z - = 0 Minimize by calculus (continued) 3. Least squares
Example 2 (1 of 3) 1.1000 1.9000 2.9000 4.0000 5.0000 6.0000 2.2000 3.0000 4.1000 5.0000 6.1000 6.9000 x = y = Fit a curve to the following data 3. Least squares
Example 2 (2 of 3) Fit z = a + b xi + c xi2 A = [[1;1;1;1;1;1], x, x.*x] = 1.0000 1.1000 1.2100 1.0000 1.9000 3.6100 1.0000 2.9000 8.4100 1.0000 4.0000 16.0000 1.0000 5.0000 25.0000 1.0000 6.0000 36.0000 b = y a b c 1.0126 1.0949 -0.0184 = (ATA)-1 AT b = Fit curve z to data 3. Least squares
Example 2 (3 of 3) error = a + b x + c x2 - y = -0.0052 0.0266 -0.0668 0.0980 -0.0726 0.0200 Error in curve fit 3. Least squares
4. Propagation of variance • Combining variance • Multiple dimensions • Example -- propagation of position • Example -- angular rotation 4. Propagation of variables
Combining variances • Variances from multiple error sources can be combined by adding variances • Example xorig = standard deviation in original position = 1 m vorig = standard deviation in original velocity = 0.5 m/s T = time between samples = 2 sec xcurrent = error in current position = square root of [(xorig)2 + (vorig * T)2] = sqrt(2) 4. Propagation of variables
Multiple dimensions • When multiple dimensions are included, covariance matrices can be added • When an error source goes through a linear transformation, resulting covariance is expressed as follows P1 = covariance of error source 1 P2 = covariance of error source 2 P = resulting covariance = P1 + P2 T = linear transformation TT = transform of linear transformation Porig = covariance of original error source P = T * P * TT 4. Propagation of variables
Example -- propagation of position xorig = standard deviation in original position = 2 m vorig = standard deviation in original velocity = 0.5 m/s T = time between samples = 4 sec xcurrent = error in current position xcurrent = xorig + T * vorig vcurrent = vorig 0 22 1 4 0 1 T = Porig = 0.52 0 1 4 0 1 0 1 0 4 1 4 4 16 = Pcurrent = T * P orig * TT = 0.25 0.25 0 4 4. Propagation of variables
Example -- angular rotation Xoriginal = original coordinates Xcurrent = current coordinates T = transformation corresponding to angular rotation y y’ cos -sin sin cos T = where = atan(0.75) x’ x 1.64 -0.48 Porig = -0.48 1.36 0.8 -0.6 0.6 0.8 0.8 0.6 -0.6 0.8 0 1.64 -0.48 2 = Pcurrent = T * P orig * TT = 1 -0.48 1.36 0 5. Statistics
5. Geometry • Unit vectors • Angle between two lines • Perpendicular to a plane • Pointing 5. Geometry
Unit vectors • A unit vector is a vector of length 1. • Unit vectors are frequently used to denote vectors that have the same direction, such as those parallel to a chosen axis of a coordinate system 5. Geometry