Statistical Computing in MATLAB

Slides:



Advertisements
Similar presentations
MATLAB – A Computational Methods By Rohit Khokher Department of Computer Science, Sharda University, Greater Noida, India MATLAB – A Computational Methods.
Advertisements

AMS597 Spring 2011 Hao Han April 05, Introduction to MATLAB The name MATLAB stands for MATrix LABoratory. Typical uses include:  Math and computation.
Introduction to Matlab Workshop Matthew Johnson, Economics October 17, /13/20151.
Review of Matrix Algebra
Getting started with Matlab Numerical Methods Appendix B help/techdoc/learn_matlab/learn_matlab.html.
Introduction to Matlab Οικονομίδης Δημήτρης
Introduction to Array The fundamental unit of data in any MATLAB program is the array. 1. An array is a collection of data values organized into rows and.
Introduction to Matlab Jianguo Wang CSSCR September 2009.
259 Lecture 15 Introduction to MATLAB. 2 What is MATLAB?  MATLAB, which stands for “MATrix LABoratory” is a high- performance language for technical.
Chapter 10 Review: Matrix Algebra
MATLAB Basics With a brief review of linear algebra by Lanyi Xu modified by D.G.E. Robertson.
MATLAB INTRO CONTROL LAB1  The Environment  The command prompt Getting Help : e.g help sin, lookfor cos Variables Vectors, Matrices, and Linear Algebra.
1 Statistical Computing in MATLAB AMS 597 Ling Leng.
Martin Ellison University of Warwick and CEPR Bank of England, December 2005 Introduction to MATLAB.
Nonparametric Econometrics1 Intro to Matlab for Data Analysis and Statistical Modeling.
You can make this in matlab!. Matlab Introduction and Matrices.
Introduction to MATLAB January 18, 2008 Steve Gu Reference: Eta Kappa Nu, UCLA Iota Gamma Chapter, Introduction to MATLAB,
MATLAB Tutorials Session I Introduction to MATLAB Rajeev Madazhy Dept of Mechanical Engineering LSU.
IC3003 B ASIC S CIENTIFIC C OMPUTING Lecture 1 Monday 08:30-11:30 U204a.
ELG 3120 Signal and System Analysis 1 Introduction to MATLAB TAs Wei Zhang Ozgur Ekici (Section A)(Section B) ELG 3120 Lab Tutorial 1.
CSE123 Lecture 5 Arrays and Array Operations. Definitions Scalars: Variables that represent single numbers. Note that complex numbers are also scalars,
1 Lab of COMP 406 Teaching Assistant: Pei-Yuan Zhou Contact: Lab 1: 12 Sep., 2014 Introduction of Matlab (I)
A brief introduction to MATLAB for students of Science, Engineering and Mathematics Jorge Lemagne Bindura University.
ECE 1304 Introduction to Electrical and Computer Engineering Section 1.1 Introduction to MATLAB.
INTRODUCTION TO MATLAB LAB# 01
Multivariate Statistics Matrix Algebra I W. M. van der Veld University of Amsterdam.
Basics of MATLAB By DR. Wafaa Shabana
Sundermeyer MAR 550 Spring Laboratory in Oceanography: Data and Methods MAR550, Spring 2013 Miles A. Sundermeyer Introduction to Matlab ® Programming.
Matlab 14.html Cost: $100 Available in labs on Windows and Unix machines.
Introduction to Matlab. What is Matlab? A software environment for interactive numerical computations Examples:  Matrix computations and linear algebra.
Matlab Screen  Command Window  type commands  Current Directory  View folders and m-files  Workspace  View program variables  Double click on a.
Introduction to Matlab Electromagnetic Theory LAB by Engr. Mian Shahzad Iqbal.
INTRODUCTION TO MATLAB DAVID COOPER SUMMER Course Layout SundayMondayTuesdayWednesdayThursdayFridaySaturday 67 Intro 89 Scripts 1011 Work
Introduction to MATLAB 1.Basic functions 2.Vectors, matrices, and arithmetic 3.Flow Constructs (Loops, If, etc) 4.Create M-files 5.Plotting.
Introduction to Matlab Patrice Koehl Department of Biological Sciences National University of Singapore
Math 252: Math Modeling Eli Goldwyn Introduction to MATLAB.
Introduction to Matlab Engr. Mian Shahzad Iqbal LAB NO.2
CS100A, Fall 1998, Lecture 201 CS100A, Fall 1998 Lecture 20, Tuesday Nov 10 More Matlab Concepts: plotting (cont.) 2-D arrays Control structures: while,
EEE 242 Computer Tools for Electrical Engineering Lecture I Mustafa KARABULUT.
Prof. N. P. Jadhav Presented by. Overview of MATLAB environment MATLAB is an interactive, matrix-based system for scientific and engineering numeric computation.
MATLAB ……………….matrix laboratory. Bhushan D Patil PhD Research Scholar Department of Electrical Engineering Indian Institute of Technology, Bombay Powai,
Linear Algebra by Dr. Shorouk Ossama.
MTH108 Business Math I Lecture 20.
ECE 1304 Introduction to Electrical and Computer Engineering
Introduction to MATLAB
Introduction to Matlab
Introduction to Mat lab
L – Modeling and Simulating Social Systems with MATLAB
Computer programming Dr. Ivan A. Hashim.
INTRODUCTION TO BASIC MATLAB
MATLAB DENC 2533 ECADD LAB 9.
Introduction to Matlab
Matlab Workshop 9/22/2018.
Introduction To MATLAB
EEE 244 Numerical Methods In Electrical Engineering
StatLab Matlab Workshop
MATH 493 Introduction to MATLAB
Introduction to MATLAB Lecture 02
Use of Mathematics using Technology (Maltlab)
Matrix Algebra - Overview
StatLab Workshop: Intro to Matlab for Data Analysis and Statistical Modeling 11/29/2018.
Matlab tutorial course
Communication and Coding Theory Lab(CS491)
Simulation And Modelling
Experiment No. (1) - an introduction to MATLAB
Announcements P3 due today
CS 111 Introduction to Computing in Engineering and Science
Matlab Training Session 2: Matrix Operations and Relational Operators
Laboratory in Oceanography: Data and Methods
Matrices and Determinants
Presentation transcript:

Statistical Computing in MATLAB AMS 597 Ling Leng

Introduction to MatLab The name MATLAB stands for matrix laboratory Typical uses include: Math and computation Algorithm development Data acquisition Modeling, simulation, and prototyping Data analysis, exploration, and visualization Scientific and engineering graphics Application development, including graphical user interface building. We will be learning how to use MATLAB in Statistics.

DESKTOP TOOLS AND DEVELOPMENT ENVIRONMENT Workspace Browser – View and make changes to the contents of the workspace. Command Windows – Run MATLAB statements (commands). M-file Editor – Creating, Editing, Debugging and Running Files.

MATRICES AND ARRAYS In MATLAB, a matrix is a rectangular array of numbers. Special meaning is sometimes attached to 1-by-1 matrices, which are scalars, and to matrices with only one row or column, which are vectors. Where other programming languages work with numbers one at a time, MATLAB allows you to work with entire matrices quickly and easily.

Entering Matrices A few basic conventions: Separate the elements of a row with blanks or commas. Use a semicolon, ; , to indicate the end of each row. Surround the entire list of elements with square brackets, [ ].

Some Matrix Functions Sum, transpose and diagonal sum(A) A’ diag(A) Subscripts: The element in row I and column j of A is denoted by A(i,j). T = A(4,5) A(4,6)=T The Colon Operator: 1:10 is a row vector containing the integers from 1 to 10.                    To obtain nounit spacing, specify an increment. For example,            100:-7:50            Subscript expressions involving colons refer to portions of a matrix:             For example, A(1:k,j) is the first k elements of the jth column of A.

Some Matrix Functions (continued) Generating Matrices Functions : Build-in functions that create square matrices of almost any size: magic(4) zeros(4,4) ones(4,4) rand(4,4) randn(4,4) Concatenating Matrices: B=[A A+32; A+48 A+16] Deleting rows or columns: X=A X(:,2)=[]

Expression Variables   MATLAB does not require any type declarations or dimension statements. When MATLAB encounters a new variable name, it automatically creates the variable and allocates the appropriate amount of storage. For example:  New_student = 25  To view the matrix assigned to any variable, simply enter the variable name.

Expression (continued) Numbers  MATLAB uses conventional decimal notation, with an optional decimal point and leading plus or minus sign, for numbers. Scientific notation uses the letter e to specify a power-of-ten scale factor. Imaginary numbers use either i or j as a suffix. Some examples of legal numbers are  3              -99            0.00019.6397238      1.60210e20     6.02252e231i             -3.14159j      3e5i

Expression (continued) Operators  + - * / ^        Functions  MATLAB provides a large number of standard elementary mathematical functions, including abs, sqrt, exp, and sin. For a list of the elementary mathematical functions, type :  help elfun  For a list of more advanced mathematical and matrix functions, type:  help specfun help elmat

Linear Algebra: Examples: A+A’ A*A’ D=det(A) R=rref(A)     % reduced row echelon form of A X=inv(A) E=eig(A)        Ploy(A)          % coefficients in the characteristics equation

Arrays: + Addition - Subtraction .* Element-by-element multiplication +    Addition -    Subtraction .* Element-by-element multiplication ./ Element-by-element division .\ Element-by-element left division .^ Element-by-element power .'   Unconjugated array transpose

Multivariate Data: MATLAB uses column-oriented analysis for multivariate statistical data. Each column in a data set represents a variable and each row an observation. The (i,j)th element is the ith observation of the jth variable. As an example, consider a data set with three variables:   Heart rate         Weight         Hours of exercise per week

Flow control: if, else, and else if switch and case if rem(n,2) ~= 0 M = odd_magic(n) elseif rem(n,4) ~= 0 M = single_even_magic(n) else M = double_even_magic(n) end switch and case switch (rem(n,4)==0) + (rem(n,2)==0)    case 0       M = odd_magic(n)    case 1       M single_even_magic(n)    case 2       M = double_even_magic(n)    otherwise       error('This is impossible') end

Flow Control (continued) For for i = 1:m for j = 1:n H(i,j) = 1/(i+j); end while a = 0; fa = -Inf; b = 3; fb = Inf; while b-a > eps*b x = (a+b)/2; fx = x^3-2*x-5; if sign(fx) == sign(fa) a = x; fa = fx; else b = x; fb = fx; end x

Graphics Basic Plotting y = sin(x); plot(x,y) xlabel('x = 0:2\pi') x = 0:pi/100:2*pi; y = sin(x); plot(x,y) xlabel('x = 0:2\pi') ylabel('Sine of x') title('Plot of the Sine Function','FontSize',12)

DATA ANALYSIS AND STATISTICS

Basic Data Analysis Import data set Scatter plot

Basic Data Analysis (continued) Covariance and Correlation Example Covariance and Correlation Coefficient Function Summary   Function Description cov Variance of vector - measure of spread or dispersion of sample variable. Covariance of matrix - measure of strength of linear relationships between variables. corrcoef Correlation coefficient - normalized measure of linear relationship strength between variables.

Preprocessing Missing Values You should remove NaN (The special value, NaN, stands for Not-a-Number in MATLAB)s from the data before performing statistical computations.

Preprocessing (continued) Removing Outliers You can remove outliers or misplaced data points from a data set in much the same manner as NaNs. Calculate the mean and standard deviation from the data set. Get the column of points that lies outside the 3*std. Remove these points Example

Regression and Curve Fitting You can find these coefficients efficiently by using the MATLAB backslash operator. Example: Ordinary least squares y=b0+b1x Polynomial Regression Example: Linear-in-the-Parameters Regression Multiple Regression

Thank you !