Chapter 7 Introduction to MATLAB for Engineers, Third Edition

Slides:



Advertisements
Similar presentations
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 ~ Curve Fitting ~ Least Squares Regression Chapter.
Advertisements

Chapter 6 The Normal Distribution In this handout: Probability model for a continuous random variable Normal distribution.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Introduction to MATLAB 7 for Engineers William J. Palm.
Introduction to Summary Statistics
Part 4 Chapter 13 Linear Regression
B a c kn e x t h o m e Classification of Variables Discrete Numerical Variable A variable that produces a response that comes from a counting process.
Simple Linear Regression Analysis
Introduction to MATLAB for Engineers, Third Edition William J. Palm III Chapter 7 Statistics, Probability, and Interpolation PowerPoint to accompany Copyright.
Copyright © 2010, 2007, 2004 Pearson Education, Inc. Lecture Slides Elementary Statistics Eleventh Edition and the Triola Statistics Series by.
Chapter 9 Numerical Integration Numerical Integration Application: Normal Distributions Copyright © The McGraw-Hill Companies, Inc. Permission required.
Hydrologic Statistics
4. Random Variables A random variable is a way of recording a quantitative variable of a random experiment.
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. Introduction to MATLAB 7 for Engineers William J. Palm.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 4 Curve Fitting.
Introduction to Summary Statistics. Statistics The collection, evaluation, and interpretation of data Statistical analysis of measurements can help verify.
1 Chapter 5. Section 5-1 and 5-2. Triola, Elementary Statistics, Eighth Edition. Copyright Addison Wesley Longman M ARIO F. T RIOLA E IGHTH E DITION.
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.
Copyright © 2010, 2007, 2004 Pearson Education, Inc. Lecture Slides Elementary Statistics Eleventh Edition and the Triola Statistics Series by.
Copyright © 2010, 2007, 2004 Pearson Education, Inc. All Rights Reserved. Section 6-1 Review and Preview.
Chapter 2 Describing Data.
Curve Fitting and Regression EEE 244. Descriptive Statistics in MATLAB MATLAB has several built-in commands to compute and display descriptive statistics.
© 2005 McGraw-Hill Ryerson Ltd. 5-1 Statistics A First Course Donald H. Sanders Robert K. Smidt Aminmohamed Adatia Glenn A. Larson.
Topics for our first Seminar The readings are Chapters 1 and 2 of your textbook. Chapter 1 contains a lot of terminology with which you should be familiar.
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.
Barnett/Ziegler/Byleen Finite Mathematics 11e1 Chapter 11 Review Important Terms, Symbols, Concepts Sect Graphing Data Bar graphs, broken-line graphs,
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 4 Chapter 15 General Least Squares and Non- Linear.
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.
IENG-385 Statistical Methods for Engineers SPSS (Statistical package for social science) LAB # 1 (An Introduction to SPSS)
Copyright © The McGraw-Hill Companies, Inc. This work is only for non-profit use by instructors in courses for which this textbook has been adopted.
Business Statistics, A First Course (4e) © 2006 Prentice-Hall, Inc. Chap 6-1 Chapter 6 The Normal Distribution Business Statistics, A First Course 4 th.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Applied Numerical Methods With MATLAB ® for Engineers.
Chapter 6 Continuous Random Variables Copyright © 2014 by The McGraw-Hill Companies, Inc. All rights reserved.McGraw-Hill/Irwin.
Descriptive Statistics: Tabular and Graphical Methods
Chapter 4: Basic Estimation Techniques
INTRODUCTION TO STATISTICS
Probability and Statistics
Discrete Random Variables
Lecture Slides Elementary Statistics Twelfth Edition
Chapter 7 Matrix Mathematics
Statistical Quality Control, 7th Edition by Douglas C. Montgomery.
Introduction to MATLAB for Engineers
Introduction to Summary Statistics
Introduction to Programming for Mechanical Engineers (ME 319)
Introduction to Summary Statistics
Laugh, and the world laughs with you. Weep and you weep alone
Introduction to Summary Statistics
The Normal Probability Distribution
Introduction to Summary Statistics
Statistical Methods For Engineers
Introduction to Summary Statistics
Introduction to Matlab
MEGN 537 – Probabilistic Biomechanics Ch.3 – Quantifying Uncertainty
Histograms REVIEWED Histograms are more than just an illustrative summary of the data sample. Typical examples are shown below (in R: see help(hist) for.
Chapter 2 Excel Fundamentals
Elementary Statistics
Introduction to Summary Statistics
Displaying Distributions with Graphs
Introduction to Summary Statistics
Statistics for Managers Using Microsoft® Excel 5th Edition
Introduction to Summary Statistics
Introduction to Summary Statistics
Further Topics on Random Variables: Derived Distributions
Further Topics on Random Variables: Derived Distributions
Further Topics on Random Variables: Derived Distributions
REGRESSION ANALYSIS 11/28/2019.
Presentation transcript:

Chapter 7 Introduction to MATLAB for Engineers, Third Edition PowerPoint to accompany Introduction to MATLAB for Engineers, Third Edition William J. Palm III Chapter 7 Statistics, Probability, and Interpolation Copyright © 2010. The McGraw-Hill Companies, Inc. This work is only for non-profit use by instructors in courses for which this textbook has been adopted. Any other use without publisher’s consent is unlawful.

Breaking Strength of Thread % 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]; % The six possible outcomes are ... 91,92,93,94,95,96. x = [91:96]; hist(y,x),axis([90 97 0 6]),... ylabel(’Absolute Frequency’),... xlabel(’Thread Strength (N)’),... title(’Absolute Frequency Histogram... for 20 Tests’) This creates the next figure. 7-2

Histograms for 20 tests of thread strength. Figure 7.1–1, page 297 7-3

Absolute frequency histogram for 100 thread tests. Figure 7.1–2. This was created by the program on page 298. 7-4

Use of the bar function for relative frequency histograms (page 299). % 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-5

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

Use of the hist function for relative frequency histograms. 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-7

Histogram functions Table 7.1–1 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. 7-8

7-9 The Data Statistics tool. Figure 7.1–4 on page 301 More? See page 300.

Scaled Frequency Histogram (pages 301-303) % 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-10

Scaled histogram of height data. Figure 7.2–1, page 302 7-11

Scaled histogram of height data for very many measurements. 7-12

The basic shape of the normal distribution curve. Figure 7.2–2, page 304 More? See pages 303-304. 7-13

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

Probability interpretation of the μ ± σ limits. 7-15

Probability interpretation of the μ ± 2σ limits. 7-16 More? See pages 431-432.

1 a - m b - m P(a £ x £ b) = erf - erf (7.2-3) s Ö2 s Ö2 2 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: 1 a - m b - m P(a £ x £ b) = erf - erf (7.2-3) s Ö2 s Ö2 2 See pages 305-306. 7-17

Sums and Differences of Random Variables (page 307) 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 mx and my, and variances s x and s y, and if u = x + y and u = x - y, then mu = mx + my (7.2–4) mu = mx - my (7.2–5) s u = s u = s x + s y (7.2–6) 2 2 2 2 2 2 7-18

Random number functions Table 7.3–1 Command rand rand(n) rand(m,n) s = rand(’twister’) rand(’twister’,s) rand(’twister’,0) rand(’twister’,j) rand(’twister’,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. 7-19

Table 7.3–1 (continued) 7-20 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(’twister’) but for the normally distributed generator. Like rand(’twister’,s) but for the normally distributed generator. Like rand(’twister’,0) but for the normally distributed generator. Like rand(’twister’,j) but for the normally distributed generator. Like rand(’twister’,sum(100*clock)) but for the normally distributed generator. Generates a random permutation of the integers from 1 to n. 7-20

>>rand(’twister’,0) >>rand ans = 0.5488 The following session shows how to obtain the same sequence every time rand is called. >>rand(’twister’,0) >>rand ans = 0.5488 0.7152 7-21

>>s = rand(’twister’); >>rand(’twister’,s) >>rand 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(’twister’); >>rand(’twister’,s) >>rand ans = 0.6028 7-22

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) + 2. 7-23

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 s and a mean of m. y = s x + m (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) + 5. 7-24

If y and x are linearly related, as y = bx + c (7.3–3) and if x is normally distributed with a mean mx and standard deviation sx, it can be shown that the mean and standard deviation of y are given by my = bmx + c (7.3–4) sy = |b|sx (7.3–5) More? See pages 310-311. 7-25

Statistical analysis and manufacturing tolerances: Example 7. 3-1 Statistical analysis and manufacturing tolerances: Example 7.3-1. Dimensions of a triangular cut. Figure 7.3–1 , page 312 7-26

Scaled histogram of the angle q. Figure 7.3–2, page 313 7-27

Applications of interpolation: A plot of temperature data versus time Applications of interpolation: A plot of temperature data versus time. Figure 7.4–1, page 314 7-28

Temperature measurements at four locations. Figure 7.4–2, page 316 More? See pages 313-317. 7-29

Linear interpolation functions. Table 7.4–1, page 317 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. 7-30

Z_int = interp2(x,y,z,x_int,y_int) Table 7.4–1 Continued 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. 7-31

>>y_int = spline(x,y,x_int); Cubic-spline interpolation: The following session produces and plots a cubic-spline fit, using an increment of 0.01 in the x values (pages 317-319). >>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([7 12 45 80]) This produces the next figure. 7-32

Linear and cubic-spline interpolation of temperature data. Figure 7.4–3, page 319 7-33

Polynomial interpolation functions. Table 7.4–2, page 320 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. 7-34

y_int = spline(x,y,x_int) Table 7.4–2 Continued 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. 7-35

Table 7.4–2 Continued y_int = pchip(x,y,x_int) Similar to spline but uses piecewise cubic Hermite polynomials for interpolation to preserve shape and respect monotonicity. 7-36

[breaks, coeffs, m, n] = unmkpp(spline(x,y)) 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. 7-37

The next slide illustrates interpolation using a cubic polynomial and an eighth order polynomial (top graph). The cubic is not satisfactory in this case, and the eighth order polynomial is not suitable for interpolation over the interval 0 < x < 0.5. The cubic spline does a better job in this case (bottom graph). 7-38

Figure 7. 4-4 Top: Cubic and eighth order polynomial interpolation Figure 7.4-4 Top: Cubic and eighth order polynomial interpolation. Bottom: Cubic spline (page 321). 7-39

The next slide illustrates interpolation using a fifth order polynomial and a cubic spline (top graph). The cubic spline is better because the fifth order polynomial displays wide variations between the data points. The pchip polynomial does a better job than the cubic spline in this case (bottom graph). 7-40

Figure 7.4-5 Top: Fifth order polynomial and cubic spline interpolation. Bottom: pchip and cubic spline interpolation. (page 323) 7-41