Copyright © 2005. The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Introduction to MATLAB 7 for Engineers William J. Palm.

Slides:



Advertisements
Similar presentations
Chapter 2 Minitab for Data Analysis KANCHALA SUDTACHAT.
Advertisements

Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 ~ Curve Fitting ~ Least Squares Regression Chapter.
Random variables 1. Note  there is no chapter in the textbook that corresponds to this topic 2.
Sampling: Final and Initial Sample Size Determination
Random Sampling and Data Description
Introduction to Summary Statistics
Introduction to Summary Statistics
QUANTITATIVE DATA ANALYSIS
Probability & Using Frequency Distributions Chapters 1 & 6 Homework: Ch 1: 9-12 Ch 6: 1, 2, 3, 8, 9, 14.
CS 351/ IT 351 Modelling and Simulation Technologies Random Variates Dr. Jim Holten.
Part 4 Chapter 13 Linear Regression
Simple Linear Regression Analysis
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. by Lale Yurttas, Texas A&M University Chapter 171 CURVE.
Chapter Six z-Scores and the Normal Curve Model. Copyright © Houghton Mifflin Company. All rights reserved.Chapter The absolute value of a number.
Introduction to MATLAB for Engineers, Third Edition William J. Palm III Chapter 7 Statistics, Probability, and Interpolation PowerPoint to accompany Copyright.
QMS 6351 Statistics and Research Methods Probability and Probability distributions Chapter 4, page 161 Chapter 5 (5.1) Chapter 6 (6.2) Prof. Vera Adamchik.
 The Law of Large Numbers – Read the preface to Chapter 7 on page 388 and be prepared to summarize the Law of Large Numbers.
Lecture II-2: Probability Review
Chapter 9 Numerical Integration Numerical Integration Application: Normal Distributions Copyright © The McGraw-Hill Companies, Inc. Permission required.
Correlation and Linear Regression
McGraw-Hill/Irwin Copyright © 2010 by The McGraw-Hill Companies, Inc. All rights reserved. Chapter 13 Linear Regression and Correlation.
Hydrologic Statistics
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 ~ Curve Fitting ~ Least Squares Regression Chapter.
Linear Regression and Correlation
© 2005 The McGraw-Hill Companies, Inc., All Rights Reserved. Chapter 12 Describing Data.
Census A survey to collect data on the entire population.   Data The facts and figures collected, analyzed, and summarized for presentation and.
Introduction to MATLAB for Engineers, Third Edition Chapter 6 Model Building and Regression PowerPoint to accompany Copyright © The McGraw-Hill Companies,
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 4 Curve Fitting.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. A Concise Introduction to MATLAB ® William J. Palm III.
Descriptive Statistics II: By the end of this class you should be able to: describe the meaning of and calculate the mean and standard deviation of a sample.
Descriptive Statistics I: By the end of this class you should be able to: Palm: Section 7.1, 7.2 Program cords and delays in your music programs plot a.
Curve Fitting and Regression EEE 244. Descriptive Statistics in MATLAB MATLAB has several built-in commands to compute and display descriptive statistics.
ES 240: Scientific and Engineering Computation. Chapter 13: Linear Regression 13. 1: Statistical Review Uchechukwu Ofoegbu Temple University.
© 2005 McGraw-Hill Ryerson Ltd. 5-1 Statistics A First Course Donald H. Sanders Robert K. Smidt Aminmohamed Adatia Glenn A. Larson.
Recap Sum and Product Functions Matrix Size Function Variance and Standard Deviation Random Numbers Complex Numbers.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. A Concise Introduction to MATLAB ® William J. Palm III.
Slide Copyright © 2008 Pearson Education, Inc. Chapter 6 The Normal Distribution.
Slide 5-1 Chapter 5 Probability and Random Variables.
Probability and Statistics in Geology Probability and statistics are an important aspect of Earth Science. Understanding the details, population of a data.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Introduction to MATLAB 7 for Engineers William J. Palm.
Review Lecture 51 Tue, Dec 13, Chapter 1 Sections 1.1 – 1.4. Sections 1.1 – 1.4. Be familiar with the language and principles of hypothesis testing.
CY1B2 Statistics1 (ii) Poisson distribution The Poisson distribution resembles the binomial distribution if the probability of an accident is very small.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 4 Chapter 15 General Least Squares and Non- Linear.
Probability Theory Modelling random phenomena. Permutations the number of ways that you can order n objects is: n! = n(n-1)(n-2)(n-3)…(3)(2)(1) Definition:
Data Analysis, Presentation, and Statistics
1 Lecture 3 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
Engineering Analysis ENG 3420 Fall 2009 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 11:00-12:00.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Introduction to MATLAB 7 for Engineers William J. Palm.
Chapter 20 Statistical Considerations Lecture Slides The McGraw-Hill Companies © 2012.
2/15/2016ENGM 720: Statistical Process Control1 ENGM Lecture 03 Describing & Using Distributions, SPC Process.
Chapter 1 Computing Tools Variables, Scalars, and Arrays Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
IENG-385 Statistical Methods for Engineers SPSS (Statistical package for social science) LAB # 1 (An Introduction to SPSS)
Correlation and Linear Regression Chapter 13 McGraw-Hill/Irwin Copyright © 2012 by The McGraw-Hill Companies, Inc. All rights reserved.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Applied Numerical Methods With MATLAB ® for Engineers.
Chapter 4: Basic Estimation Techniques
Review 1. Describing variables.
Chapter 7 Introduction to MATLAB for Engineers, Third Edition
Introduction to Programming for Mechanical Engineers (ME 319)
Chapter 12 Statistics 2012 Pearson Education, Inc.
Introduction to Summary Statistics
Introduction to Summary Statistics
Introduction to Summary Statistics
Introduction to Summary Statistics
Introduction to Summary Statistics
Introduction to Normal Distributions
Chapter 5 Normal Probability Distributions.
Introduction to Normal Distributions
REGRESSION ANALYSIS 11/28/2019.
Presentation transcript:

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Introduction to MATLAB 7 for Engineers William J. Palm III Chapter 7 Probability, Statistics, and Interpolation PowerPoint to accompany

Agenda Histograms – absolute vs relative  Histograms – absolute vs relative  Bar charts Bar charts Scaled frequency histograms Scaled frequency histograms Normal Distribution Curve and it's meaning Normal Distribution Curve and it's meaning Random number generation Random number generation Interpolating Data Interpolating Data

An example of a histogram: test scores for 20 students. Figure 7.1–1 7-2 Bins number in each bin

Absolute Frequency Histogram -- actual number of outcomes in ea. bin % Thread breaking strength data for 20 tests. y = [92,94,93,96,93,94,95,96,91,93,95,95,95,92,93,94, 91,94,92,93]; % six possible outcomes = 91,92,93,94,95,96. x = [91:96]; hist(y,x),axis([ ]) ylabel('Absolute Frequency') xlabel('Thread Strength (N)') title('Absolute Frequency Histogram for 20 Tests') This creates the next figure. 7-3

Histograms for 20 tests of thread strength. Figure 7.1–2 7-4

Absolute frequency histogram for 100 thread tests. Figure 7.1–3. This was created by the program on page

Variations of hist() hist(y) plots data vector y in histogram hist(y) plots data vector y in histogram with 10 bins hist(y,n) plots data vector y in histogram hist(y,n) plots data vector y in histogram with n bins hist(y,x) plots data vector y in histogram with bins determined by x vector. hist(y,x) plots data vector y in histogram with bins determined by x vector.

Relative Frequency Histogram Shows fraction of total appearing in each bin Shows fraction of total appearing in each bin Sum of all bins = 1 Sum of all bins = 1 ABSOLUTERELATIVE ABSOLUTERELATIVE

Hist() only does absolute histograms Use the bar function for relative frequency histograms. % Relative frequency histogram using the bar function. tests = 100; y = [13,15,22,19,17,14]/tests; x = [91:96]; bar(x,y),ylabel('Relative Frequency') xlabel('Thread Strength (N)') title('Relative Frequency Histogram for 100 Tests') This creates the next figure. 7-6 pre "bin-ified" data the bins

Relative frequency histogram for 100 thread tests. Figure 7.1–4 7-7

hist( ) can also pre-sort your data into bins Then bar() can do the plot. tests = 100; y = [91*ones(1,13),92*ones(1,15),93*ones(1,22), 94*ones(1,19),95*ones(1,17),96*ones(1,14)]; x = [91:96]; [z,x] = hist(y,x); bar(x,z/tests) ylabel('Relative Frequency') xlabel('Thread Strength (N)') title('Relative Frequency Histogram for 100 Tests') This also creates the previous figure. 7-8 sort data into bins

Command bar(x,y) hist(y) hist(y,n) hist(y,x) [z,x] = hist(y) [z,x] = hist(y,n) [z,x] = hist(y,x) Description Creates a bar chart of y versus x. Aggregates the data in the vector y into 10 bins evenly spaced between the minimum and maximum values in y. Aggregates the data in the vector y into n bins evenly spaced between the minimum and maximum values in y. Aggregates the data in the vector y into bins whose center locations are specified by the vector x. The bin widths are the distances between the centers. Same as hist(y) but returns two vectors z and x that contain the frequency count and the bin locations. Same as hist(y,n) but returns two vectors z and x that contain the frequency count and the bin locations. Same as hist(y,x) but returns two vectors z and x that contain the frequency count and the bin locations. The returned vector x is the same as the user-supplied vector x. Histogram functions Table 7.1–1 7-9

The Data Statistics tool. Figure 7.1– More? See page 424.

Comparison of theory and experiment for 100 rolls of a single die. Figure 7.1–6 7-11

Comparison of theory and experiment for 100 rolls of two dice. Figure 7.1– More? See pages 424 – 427.

Scaled Frequency Histogram Absolute histogram Absolute histogram actual number of counts actual number of counts sum of bin heights = total number of data samples sum of bin heights = total number of data samples Relative frequency histogram Relative frequency histogram proportional number of counts proportional number of counts sum of bin heights = 1 sum of bin heights = 1 Scaled frequency histogram Scaled frequency histogram total area under all bins = 1 total area under all bins = 1 (sum of bin heights) * binwidth = 1 (sum of bin heights) * binwidth = 1 useful for calculating probabilities useful for calculating probabilities

Scaled Frequency Histogram % Absolute frequency data. y_abs=[1,0,0,0,2,4,5,4,8,11,12,10,9,8,7,5,4,4,3,1,1,0,1]; binwidth = 0.5; % Compute scaled frequency data. area = binwidth*sum(y_abs); y_scaled = y_abs/area; % Define the bins. bins = [64:binwidth:75]; % Plot the scaled histogram. bar(bins,y_scaled) ylabel('Scaled Frequency'),xlabel('Height (in.)') This creates the next figure. 7-13

Scaled histogram of height data. Figure 7.2– More? See pages

Scaled histogram of height data for very many measurements. Figure 7.2– More? See pages

Normal Distribution Curve The basic shape of the normal distribution curve. Figure 7.2– More? See pages 429 – 431.

The effect on the normal distribution curve of increasing σ. For this case μ = 10, and the three curves correspond to σ = 1, σ = 2, and σ = 3. Figure 7.2–4 7-17

Probability interpretation of the μ ± σ limits. Figure 7.2–5 7-18

Probability interpretation of the μ ± 2σ limits. Figure 7.2–5 (continued) 7-19 More? See pages

The probability that the random variable x is no less than a and no greater than b is written as P(a  x  b). It can be computed as follows: P(a  x  b)  1 2 b  b    2 erf  erf a  a    2 (7.2  5) Error Function in matlab the function erf() can be used for the above calculation in matlab the function erf() can be used for the above calculation More? See pages

Random Number Generation Two basic PDFs are used throughout technical computing world: Two basic PDFs are used throughout technical computing world: Normal -- gaussian "bell curve" with mean and standard deviation as discussed Normal -- gaussian "bell curve" with mean and standard deviation as discussed Uniform – flat distribution, all values equally likely to occur Uniform – flat distribution, all values equally likely to occur

Sums and Differences of Random Variables It can be proved that the mean of the sum (or difference) of two independent normally distributed random variables equals the sum (or difference) of their means, but the variance is always the sum of the two variances. That is, if x and y are normally distributed with means  x and  y, and variances  x and  y, and if u  x  y and  x  y, then  u  x  y (7.2–6)    x  y (7.2–7)  u    x  y (7.2–8)

Command rand rand(n) rand(m,n) s = rand(’state’) rand(’state’,s) rand(’state’,0) rand(’state’,j) rand(’state’,sum(100*clock)) Description Generates a single uniformly distributed random number between 0 and 1. Generates an n  n matrix containing uniformly distributed random numbers between 0 and 1. Generates an m  n matrix containing uniformly distributed random numbers between 0 and 1. Returns a 35-element vector s containing the current state of the uniformly distributed generator. Sets the state of the uniformly distributed generator to s. Resets the uniformly distributed generator to its initial state. Resets the uniformly distributed generator to state j, for integer j. Resets the uniformly distributed generator to a different state each time it is executed. Random number functions Table 7.3–1 7-22

randn randn(n) randn(m,n) s = randn(’state’) randn(’state’,s) randn(’state’,0) randn(’state’,j) randn(’state’,sum(100*clock)) randperm(n) Generates a single normally distributed random number having a mean of 0 and a standard deviation of 1. Generates an n  n matrix containing normally distributed random numbers having a mean of 0 and a standard deviation of 1. Generates an m  n matrix containing normally distributed random numbers having a mean of 0 and a standard deviation of 1. Like rand(’state’) but for the normally distributed generator. Like rand(’state’,s) but for the normally distributed generator. Like rand(’state’,0) but for the normally distributed generator. Like rand(’state’,j) but for the normally distributed generator. Like rand(’state’,sum(100*clock)) but for the normally distributed generator. Generates a random permutation of the integers from 1 to n Table 7.3–1 (continued)

Repeating Randomness (useful for simulation) The following session shows how to obtain the same sequence every time rand is called. >>rand('state',0) >>rand ans = >>rand ans = >>rand('state',0) >>rand ans = >>rand ans =

You need not start with the initial state in order to generate the same sequence. To show this, continue the above session as follows. >>s = rand('state'); >>rand('state',s) >>rand ans = >>rand('state',s) >>rand ans =

Generating a Uniform Distribution The general formula for generating a uniformly distributed random number y in the interval [a, b] is y  (b  a) x  a (7.3–1) where x is a random number uniformly distributed in the interval [0, 1]. For example, to generate a vector y containing 1000 uniformly distributed random numbers in the interval [2, 10], you type y = 8*rand(1,1000)

Example 7.3-1:Profit versus quantity plot for 5000 simulations. Figure 7.3–1 7-27

Generating a Normal Distribution If x is a random number with a mean of 0 and a standard deviation of 1, use the following equation to generate a new random number y having a standard deviation of  and a mean of . y  x  (7.3–2) For example, to generate a vector y containing 2000 random numbers normally distributed with a mean of 5 and a standard deviation of 3, you type y = 3*randn(1,2000)

If y and x are linearly related, as y  bx  c(7.3–3) and if x is normally distributed with a mean  x and standard deviation  x, it can be shown that the mean and standard deviation of y are given by  y  b  x  c(7.3–4)  y  b  x (7.3–5) 7-29 More? See pages 442 – 444.

Statistical analysis and manufacturing tolerances: Example Dimensions of a triangular cut. Figure 7.3–2 7-30

Scaled histogram of the angle . Figure 7.3– More? See pages 443 – 444.

Agenda Histograms – absolute vs relative Histograms – absolute vs relative Bar charts Bar charts Scaled frequency histograms Scaled frequency histograms Normal Distribution Curve and it's meaning Normal Distribution Curve and it's meaning Random number generation Random number generation Interpolating Data  Interpolating Data 

Applications of interpolation: A plot of temperature data versus time. Figure 7.4–1 7-32

Temperature measurements at four locations. Figure 7.4– More? See pages

Command Y_int = interp1(x,y,x_int) Description Used to linearly interpolate a function of one variable: y  f (x). Returns a linearly interpolated vector y_int at the specified value x_int, using data stored in x and y. Linear interpolation functions. Table 7.4–1 7-34

Z_int = interp2(x,y,z,x_int,y_int) Used to linearly interpolate a function of two variables: y  f (x, y). Returns a linearly interpolated vector z_int at the specified values x_int and y_int, using data stored in x, y, and z Table 7.4–1 Continued

Cubic-spline interpolation: The following session produces and plots a cubic-spline fit, using an increment of 0.01 in the x values. >>x = [7,9,11,12]; >>y = [49,57,71,75]; >>x_int = [7:0.01:12]; >>y_int = spline(x,y,x_int); >>plot(x,y,’o’,x,y,’--’,x_int,y_int),... xlabel(’Time (hr)’),ylabel(’Temperature (deg F)’,... title(’Temperature Measurements at a Single Location’),... axis([ ]) This produces the next figure. 7-36

Linear and cubic-spline interpolation of temperature data. Figure 7.4– More? See pages

Command y_est = interp1(x,y,x_est,’spline’) Description Returns a column vector y_est that contains the estimated values of y that correspond to the x values specified in the vector x_est, using cubic-spline interpolation. Polynomial interpolation functions. Table 7.4–2 7-38

Y_int = spline(x,y,x_int) Computes a cubic-spline interpolation where x and y are vectors containing the data and x_int is a vector containing the values of the independent variable x at which we wish to estimate the dependent variable y. The result Y_int is a vector the same size as x_int containing the interpolated values of y that correspond to x_int Table 7.4–2 Continued

[breaks, coeffs, m, n] = unmkpp(spline(x,y)) Computes the coefficients of the cubic-spline polynomials for the data in x and y. The vector breaks contains the x values, and the matrix coeffs is an m  n matrix containing the polynomial coefficients. The scalars m and n give the dimensions of the matrix coeffs ; m is the number of polynomials, and n is the number of coefficients for each polynomial Table 7.4–2 Continued

Robot arm control: A robot arm having two joints. (a) Dimensions and arm angles. (b) The hand’s path is not a straight line, but a complicated curve. Figure 7.4–4 7-41

Path of a robot hand using three knot points. Figure 7.4– More? See pages