Statistics-2 Chp7 Engr/Math/Physics 25 Bruce Mayer, PE

advertisement

Engr/Math/Physics 25

Chp7

Statistics-2

Bruce Mayer, PE

Licensed Electrical & Mechanical Engineer

BMayer@ChabotCollege.edu

Bruce Mayer, PE

BMayer@ChabotCollege.edu • ENGR-25_Lec-20_Statistics-2.ppt

Engineering/Math/Physics 25: Computational Methods

1

Learning Goals

 Create HISTOGRAM Plots

 Use MATLAB to solve Problems in

• Statistics

• Probability

 Use Monte Carlo (random) Methods to Simulate Random processes

 Properly Apply Interpolation to

Estimate values between or outside of know data points

Engineering/Math/Physics 25: Computational Methods

2

Bruce Mayer, PE

BMayer@ChabotCollege.edu • ENGR-25_Lec-20_Statistics-2.ppt

Random Numbers (RNs)

 There is no such thing as a ‘‘random number”

• is 53 a random number? (need a Sequence )

 Definition: a SEQUENCE of statistically

INDEPENDENT numbers with a Defined

DISTRIBUTION (often uniform; often not)

• Numbers are obtained completely by chance

• They have nothing to do with the other numbers in the sequence

 Uniform distribution → each possible number is equally probable

Engineering/Math/Physics 25: Computational Methods

3

Bruce Mayer, PE

BMayer@ChabotCollege.edu • ENGR-25_Lec-20_Statistics-2.ppt

Random Number Generator

 von Neumann (ca. 1946) Developed the

Middle Square Method

 take the square of the previous number and extract the middle digits

 example: four-digit numbers

• r i

= 8269

• r i +1

= 3763 ( r i

2

• r i +2

• r i +3

= 1601 (

= 6320 ( r r

= 68376361) i +1

2 i +2

2

= 14160169)

= 2563201)

Engineering/Math/Physics 25: Computational Methods

4

Bruce Mayer, PE

BMayer@ChabotCollege.edu • ENGR-25_Lec-20_Statistics-2.ppt

PSUEDO-Random Number

 Most Computer Based Random Number

Generators are Actually PSUEDO-Random in implementation

 Note that for the von Nueman Method

• Each number is COMPLETELY determined by its predecessor

• The sequence is NOT random but appears to be so statistically → pseudo-random numbers

 All random number generators based on an algorithmic operation have their own built-in characteristics

• MATLAB uses a 35 Element “seed”

Engineering/Math/Physics 25: Computational Methods

5

Bruce Mayer, PE

BMayer@ChabotCollege.edu • ENGR-25_Lec-20_Statistics-2.ppt

Random Number Commands

Command

Rand

Description

Generates a single uniformly distributed random number between 0 and 1. rand(n) uniformly distributed random numbers between 0 and 1. rand(m,n) s = rand(’state’) rand(’state’,s) rand(’state’,0) rand(’state’,j) rand(’state’,sum(100*clock))

Engineering/Math/Physics 25: Computational Methods

6 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

Bruce Mayer, PE

BMayer@ChabotCollege.edu • ENGR-25_Lec-20_Statistics-2.ppt

Some (psuedo)Random No.s

0.30253

0.35572

0.8678 0.065315

0.98548

0.62339

0.50921

0.76267

0.85184 0.049047

0.37218

0.2343 0.017363

0.68589

0.07429

0.7218

0.75948

0.75534

0.07369

0.9331

0.81939

0.67735

0.19324

0.65164

0.94976

0.89481

0.19984 0.063128

0.62114

0.87683

0.3796

0.75402

0.55794

0.28615 0.049493

0.26422

0.56022 0.012891

0.27643

0.66316

0.014233

0.2512

0.56671

0.99953

0.24403

0.3104

0.77088

0.88349

0.59618

0.93274

0.12192

0.21199

0.82201

0.77908

0.31393

0.27216

0.81621

0.13098

0.52211

0.49841

0.26321

0.3073

0.63819

0.41943

0.97709

0.94082

0.11706

0.29049

0.75363

0.92668

0.98657

0.21299

0.22191

0.70185

0.76992

0.67275

0.65964

0.67872

0.50288

0.0356

0.70368

0.84768

0.37506

0.95799

0.21406 0.074321

0.9477 0.081164

0.52206

0.20927

0.82339

0.76655

0.60212 0.070669

0.82803

0.85057

0.9329

0.45509 0.046636

0.66612

0.60494

0.01193

0.91756

0.3402

0.71335 0.081074

0.59791

0.13094

0.6595

0.22715

0.11308

0.46615

0.22804

0.85112

0.94915 0.095413

0.18336

0.51625

0.81213

0.91376

0.44964

0.56205

0.2888 0.014864

0.63655

0.4582

0.90826

0.22858

0.1722

0.3193

0.88883

0.28819

0.17031

0.7032

0.15638

0.86204

0.96882

0.3749

0.10159

0.81673

0.5396

0.58248

0.12212

0.65662

7

MATLAB Command → RandTab2 = rand(18,8);

Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE

BMayer@ChabotCollege.edu • ENGR-25_Lec-20_Statistics-2.ppt

Random No. Simulation

 Started During WWII for the purpose of Developing

InExpensive methods for testing engineered systems by IMITATING their Real

Behavior

 These Methods are Usually called MONTE CARLO

Simulation Techniques

Engineering/Math/Physics 25: Computational Methods

8

Bruce Mayer, PE

BMayer@ChabotCollege.edu • ENGR-25_Lec-20_Statistics-2.ppt

Monte Carlo Simulation (1)

 The Basis for These Methods

• Develop a Computer-Based Analytical

Model, or Equation/Algorithm, that

(hopefully) Predicts System Behavior

• The Model is then Evaluated Many Times to Produce a STATISTICAL PROBABILITY for the System Behavior

• Each Evaluation (or Simulation) Cycle is based on Randomly -Set Values for

System Input/Operating Parameters

Engineering/Math/Physics 25: Computational Methods

9

Bruce Mayer, PE

BMayer@ChabotCollege.edu • ENGR-25_Lec-20_Statistics-2.ppt

Monte Carlo (2)

• Analytical Tools are Used to ensure that the Random assignment of Input

Parameter Values meet the Desired

Probability Distribution Function

 The Result of MANY Random Trials

Yields a Statistically Valid Set of

Predictions

• Then Use standard Stat Tools to Analyze

Result to Pick the “Best” Overall Value

– e.g.: Mean, Median, Mode, Max, Min, etc.

Engineering/Math/Physics 25: Computational Methods

10

Bruce Mayer, PE

BMayer@ChabotCollege.edu • ENGR-25_Lec-20_Statistics-2.ppt

Monte Carlo Process Steps

1. Define the System

2. Generate (psuedo)Random No.s

3. Generate Random VARIABLES

• Usually Involves SCALING and/or

OFFSETTING the RNs

4. Evaluate the Model N-Times; each time using Different Random Vars

5. Statistical Analysis of the N-trial

Results to assess Validity & Values

Engineering/Math/Physics 25: Computational Methods

11

Bruce Mayer, PE

BMayer@ChabotCollege.edu • ENGR-25_Lec-20_Statistics-2.ppt

Monte Carlo System

 The System Definition Should Include

• Boundaries (Barriers that don’t change)

• Input Parameters

• Output (Behavior) Parameters

• Processes (Architecture) that Relate the

Input Parameters to the Output Parameters

Engineering/Math/Physics 25: Computational Methods

12

Bruce Mayer, PE

BMayer@ChabotCollege.edu • ENGR-25_Lec-20_Statistics-2.ppt

Fixed Model Architecture

 The Model is assumed to be

UNvarying; i.e., it behaves as a Math

FUNCTION

 Example: SPICE

• SPICE ≡ S imulation

P rogram with

I ntegrated Circuit

E mphasis (UCB)

13

 SPICE has Monte

Carlo BUILT-IN

Engineering/Math/Physics 25: Computational Methods

 SPICE uses

• UNchanging Physical

Laws  KVL & KCL

• IDEAL Circuit

Elements

I/V

Sources, R, C, L

Component

VALUES for

R, L, C, Vs, and Q can

Vary

Randomly

Bruce Mayer, PE

BMayer@ChabotCollege.edu • ENGR-25_Lec-20_Statistics-2.ppt

Monte Carlo Summarized

 Monte Carlo Method : Probabilistic simulation technique used when a process has a random component

1. Identify a

Probability Distribution

Function (PDF)

2. Setup intervals of random numbers to match probability distribution

3. Obtain the random numbers

4. Interpret the results

Engineering/Math/Physics 25: Computational Methods

14

Bruce Mayer, PE

BMayer@ChabotCollege.edu • ENGR-25_Lec-20_Statistics-2.ppt

MATLAB RANDOM No. PDFs

 MATLAB rand command produces

RNs with a Uniform

Distribution

• i.e., ANY Value over

[0,1] just as likely as

Any OTHER

 MATLAB randn , by

Contrast, produces a NORMAL

Distribution

• i.e., The MIDDLE

Value is MORE

Likely than any other

Engineering/Math/Physics 25: Computational Methods

15

Bruce Mayer, PE

BMayer@ChabotCollege.edu • ENGR-25_Lec-20_Statistics-2.ppt

Scaling rand

 rand covers the interval [0,1] – To cover [a,b] SCALE &

OFFSET the

Random No.

y

• Let x be a random

No. over [0,1], then a random number

 y over [a,b]

 b

 a

 x

 a

Engineering/Math/Physics 25: Computational Methods

16

 Example: Use rand to Produce

Uniformly Dist

Random No over

[19,37]

>> y =(37-19)*rand + 19

• Example Result

>> y =(37-19)*rand + 19 y =

36.1023

>> y =(37-19)*rand + 19 y =

23.1605

Bruce Mayer, PE

BMayer@ChabotCollege.edu • ENGR-25_Lec-20_Statistics-2.ppt

Scaled & Offset Random No.s

33.0445 28.8462 30.5977 24.5998 20.5393 19.6793 19.5497 20.0731

26.0153 24.3338 25.8150 35.6208 23.7247 34.9330 32.3933 31.2755

23.3504 32.4045 33.6084 26.7437 33.4183 35.4392 28.0004 19.7638

26.2704 22.4012 28.5909 22.3267 19.5260 33.3313 27.6386 20.2860

20.7362 31.3620 25.3131 35.2879 35.7194 20.7768 35.2850 28.3897

21.3755 22.3032 35.9020 36.6355 32.1460 23.7137 29.9776 20.7411

35.9569 25.6327 34.7670 26.8997 27.7950 25.0364 30.1180 33.7267

36.2104 30.2611 28.9028 21.0001 29.4135 31.2351 34.4700 33.7158

29.3538 33.0441 30.2046 23.6452 23.2711 21.4580 33.4988 32.0039

20.0760 20.4603 29.5668 26.3570 27.2593 31.9821 29.3810 21.6976

23.2260 35.7289 22.7394 29.7081 36.3356 20.9217 22.2926 30.8729

25.3569 32.9628 24.4224 23.7198 28.8425 30.7676 23.3188 28.3347

33.7815 27.7622 27.4766 29.8512 28.3804 27.8951 34.9572 36.5135

19.2773 26.8455 23.1488 31.8019 23.1687 33.0229 19.5161 30.6818

19.7744 27.0421 34.1976 22.9914 27.8002 31.8707 27.8182 33.4060

22.0418 24.5143 22.5058 21.1135 30.2331 35.2670 22.0227 27.1684

30.6841 28.1532 23.0666 24.3402 31.2244 35.0366 36.6163 26.7830

32.1710 28.1939 22.0727 24.7380 26.1193 25.0149 31.8285 33.8556

30.6594 33.7173 23.0980 26.6350 25.6139 31.5774 28.0085 20.5025

27.1166 33.3070 26.8426 28.1414 36.7837 22.5606 27.4796 21.3971

rand1937 = (37-

19)*rand(20,8) + 19

>> Rmax

=max(max(rand1937))

Rmax =

36.7837

>> Rmin = min(min(rand1937))

Rmin =

19.2773

Engineering/Math/Physics 25: Computational Methods

17

Bruce Mayer, PE

BMayer@ChabotCollege.edu • ENGR-25_Lec-20_Statistics-2.ppt

Scaling randn

 randn Produces a

Normal Dist. with

µ = 0, and σ = 1

• Let v be a normal random No. with µ=0

& σ=1, then a random number w with

µ = p & σ = r w

 rv

 p

Engineering/Math/Physics 25: Computational Methods

18

 Example: Use randn to Produce

Normal Dist with

µ = –17 & σ = 2.3

>> w =(2.3)*randn - 17

• Example Result

>> w =(2.3)*randn - 17 w =

-20.8308

>> w =(2.3)*randn - 17 w =

-16.7117

Bruce Mayer, PE

BMayer@ChabotCollege.edu • ENGR-25_Lec-20_Statistics-2.ppt

rand vs randn – scaled and offset

140

 rand

120

100 rand

80

60

40

20

0

0 10 20 30 40 50 60 70 80 90

RN100 = 100*rand(10000,1); hist(RN100,100), title('rand')

100

Engineering/Math/Physics 25: Computational Methods

19

 randn

350

300

250

200

150 randn

100

50

0

-300 -200 -100 0 100 200 300 400 500

Norm100 = 100*randn(10000,1)

+ 100 hist(Norm100,100), title('randn')

Bruce Mayer, PE

BMayer@ChabotCollege.edu • ENGR-25_Lec-20_Statistics-2.ppt

Monte Carlo Example (1)

 Build a Wharehouse from PreCast

Concrete (a Tilt-Up) Per PERT Chart

1. Project Start

A

2

B

D

4

E

5

F

6

G

7

H

1. Project End

C 3

 PERT

Program Evaluation and

Review Technique

• A Scheduling Tool Developed for the USA Space Program

Engineering/Math/Physics 25: Computational Methods

20

Bruce Mayer, PE

BMayer@ChabotCollege.edu • ENGR-25_Lec-20_Statistics-2.ppt

Monte Carlo Example (2)

2

A

B

E F G H

1. Project Start

4 5 6 7

D

C 3

1. Project End

 In This Case The Schedule Elements

A. Excavate Foundation

B. Construct Foundation

C. Fabricate PreCast

Components

D. Ship PreCast Parts to Building Site

Engineering/Math/Physics 25: Computational Methods

21

E. Install PreCast Parts on Foundation

F. Build Roof

G. Finish Interior and Exterior

H. Inspect Result

Bruce Mayer, PE

BMayer@ChabotCollege.edu • ENGR-25_Lec-20_Statistics-2.ppt

Monte Carlo Example (3)

 Task Durations → Normal Random Variables

• Assume Normally Distributed

Task

ID

Task Description

Mean Duration

(days)

Std Dev

(days)

1 A Foundation Excavation

B Pour Foundation

C Fab PreCast Elements

D Ship PreCast Parts

E Tilt-Up PreCast Parts

F Roofing

3.5

2.5

5

0.5

5

2

0.5

1

0.5

1.5

1

G Finish Work 4

Expected Duration = 17 Days

Engineering/Math/Physics 25: Computational Methods

22

Bruce Mayer, PE

BMayer@ChabotCollege.edu • ENGR-25_Lec-20_Statistics-2.ppt

1

Monte Carlo Example (4)

 Analytical Model

• Foundation-Work and PreCasting

Done in PARALLEL

– One will be The GATING Item before Tilt-Up

• Other Tasks Sequential

 Mathematical Model t bld

 max

A

B , C

D

E

F

G

Early GATE

Engineering/Math/Physics 25: Computational Methods

23

Bruce Mayer, PE

BMayer@ChabotCollege.edu • ENGR-25_Lec-20_Statistics-2.ppt

Monte Carlo Example (5)

Task-A Task-B Task-C Task-D Task-E Task-F Task-G Task-Sum

4.82

2.47

6.32

0.61

2.86

1.85

3.75

1.77

2.29

4.39

0.86

5.51

2.88

4.14

3.35

2.46

5.29

1.08

6.21

0.64

4.06

3.28

2.79

4.70

1.07

4.73

0.53

4.70

3.94

2.78

4.31

0.92

1.64

3.10

4.00

1.89

1.89

5.21

0.61

3.49

1.55

4.70

3.04

2.52

5.80

0.95

5.21

0.38

3.18

3.93

2.13

5.56

-0.19

5.69

2.63

4.19

2.49

2.33

5.44

-0.30

3.95

0.92

4.50

5.23

2.85

4.25

0.61

4.66

1.15

4.17

3.61

1.93

4.32

0.36

5.98

0.75

3.70

3.02

2.99

6.76

1.21

6.37

2.33

4.03

2.00

2.29

4.98

0.61

3.49

1.34

4.28

2.31

2.11

5.27

1.27

3.42

2.63

3.60

3.19

2.20

6.26

0.93

1.84

1.64

4.28

1.94

2.40

4.57

0.75

3.69

2.08

3.74

2.09

2.31

4.54

0.35

4.55

0.41

4.55

4.82

2.44

4.26

0.61

4.40

2.06

3.12

5.19

2.66

5.72

1.30

1.90

1.26

4.09

4.03

2.22

5.30

-0.11

4.72

1.70

4.48

15.74

17.78

17.29

16.03

15.46

15.56

15.51

18.57

14.52

18.07

15.98

20.71

14.70

16.19

14.95

14.83

14.40

16.85

15.10

17.14

Engineering/Math/Physics 25: Computational Methods

24

Run-1

• µ = 16.27

Days

• σ = 1.61

Days

See some

Negative

Durations!

• May want to Adjust

Bruce Mayer, PE

BMayer@ChabotCollege.edu • ENGR-25_Lec-20_Statistics-2.ppt

Monte Carlo Example (6)

Task-A Task-B Task-C Task-D Task-E Task-F Task-G Task SUM

2.79

2.26

3.02

0.77

3.67

1.86

4.56

4.98

1.59

6.63

0.99

3.18

-0.79

4.08

2.12

2.76

3.46

0.00

5.11

1.34

3.95

3.47

2.76

7.77

0.63

5.84

-1.10

4.73

1.94

2.43

4.26

0.05

6.85

2.49

4.46

2.87

3.33

3.37

0.28

4.18

1.21

3.56

5.40

2.73

6.02

0.50

5.12

3.51

3.76

3.40

2.26

4.49

0.46

4.32

0.44

4.57

3.73

2.13

6.29

0.69

2.79

1.63

4.14

4.45

2.21

5.34

-0.23

4.73

2.45

3.92

3.44

1.80

7.21

1.30

3.41

2.03

3.89

3.92

2.69

5.49

0.11

2.87

2.43

4.18

3.42

3.27

5.75

-0.14

6.65

2.88

4.75

3.32

2.70

4.39

1.09

5.56

1.25

3.84

3.75

2.85

4.44

0.76

4.73

2.89

4.38

4.16

2.62

4.64

-0.07

3.92

0.79

4.63

2.52

2.43

6.39

0.87

3.08

0.61

3.41

3.61

2.51

4.06

0.00

6.38

1.49

3.78

4.16

2.49

3.24

0.00

7.21

1.98

4.60

4.16

1.40

4.27

0.85

3.47

3.00

4.53

15.00

15.54

17.76

17.84

16.08

20.98

16.67

18.59

15.13

14.10

15.28

17.85

18.16

15.16

20.51

16.11

14.36

17.76

20.45

16.56

 Run-2

• µ = 16.99

Days

• σ = 2.05

Days

Engineering/Math/Physics 25: Computational Methods

25

Bruce Mayer, PE

BMayer@ChabotCollege.edu • ENGR-25_Lec-20_Statistics-2.ppt

Monte Carlo Example (7)

% Bruce Mayer, PE • ENGR25 • 25Oct11

% Normal Dist Task Duration on PERT Chart

% file = Monte_Carlo_Wharehouse.m

 The MATLAB

26

%

% Use 20 Random No.s for Simulation

% Set 20-Val Row-Vectors for Task Durations

% for k = 1:20; tA(k) = 1*randn + 3.5;

Script File tB(k) = 0.5*randn + 2.5; tC(k) = 1*randn + 5; tD(k) = 0.5*randn + 0.5; tE(k) = 1.5*randn + 5; tF(k) = 1*randn + 2; tG(k) = 0.5*randn + 4; end

%

% Calc Simulated Durations per Model for k = 1:20; tSUM(k) = max((tA(k)+tB(k)),(tC(k)+tD(k)))+tE(k)+tF(k)+tG(k); end

%

% Put into Table for Display Purposes

% t_tbl =[tA',tB',tC',tD',tE',tF',tG',tSUM']

% tmu = mean(tSUM)

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

BMayer@ChabotCollege.edu • ENGR-25_Lec-20_Statistics-2.ppt

Monte Carlo Example (8)

 Just for Fun Try 1000 Random

Simulation Cycles

2

A

B

E F G

1. Project Start

4 5 6 7

D C 3

 µ

1000

= 17.3730 days

• Expected 17

 σ

1000

= 2.1603 days

• Expected 2.1794 by RMS calc

H

Engineering/Math/Physics 25: Computational Methods

27

1. Project End

Bruce Mayer, PE

BMayer@ChabotCollege.edu • ENGR-25_Lec-20_Statistics-2.ppt

Linear Interpolation (1)

 During a Hardness Testing Lab in

ENGR45 we measure the HRB at 67.3 on a ½” Round Specimen

 The Rockwell Tester was Designed for

FLAT specimens, so the Instruction manual includes a TABLE for ADDING an amount to the Round-Specimen

Measurement to Obtain the

CORRECTED Value

Engineering/Math/Physics 25: Computational Methods

28

Bruce Mayer, PE

BMayer@ChabotCollege.edu • ENGR-25_Lec-20_Statistics-2.ppt

Linear Interpolation (2)

 From the Rockwell Tester Manual

67.3

• To Apply LINEAR interpolation Need to

Find Only the Data Surrounding:

– The Independent (Measured) Variable

– The Corresponding Dependent Variable Values

Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE

BMayer@ChabotCollege.edu • ENGR-25_Lec-20_Statistics-2.ppt

29

Linear Interpolation (3)

30

 Then the Linear Interpolation Eqn y y int hi

 y y lo lo

 x x act hi

 x x lo lo

 A Proportionality , Where

• x act

 actual

MEASURED value

• y int

Unknown

INTERPOLATED value

• x lo

TABULATED

Value Just Below x act

• x hi

TABULATED

Value Just Above x act

Engineering/Math/Physics 25: Computational Methods

• y lo

TABULATED Value

Corresponding to x lo

• y hi

TABULATED Value

Corresponding to x hi

Bruce Mayer, PE

BMayer@ChabotCollege.edu • ENGR-25_Lec-20_Statistics-2.ppt

Linear InTerp PorPortionality

y y int hi

 y y lo lo

 x x act hi

 x x lo lo

 i.e.; y int

y lo is to y hi

y lo x act

x lo

AS is to x hi

x lo

Bruce Mayer, PE

BMayer@ChabotCollege.edu • ENGR-25_Lec-20_Statistics-2.ppt

Engineering/Math/Physics 25: Computational Methods

31

InTerp

Pt-Slope Line Eqn

 It’s LINEAR as the Interp

Eqn can be cast into the y

 y

1 familiar Point-Slope Eqn

 m

 x

 x

1

 y int y hi

 ReWorking the Interp Equation

Let y y lo lo m x act

 x x act hi

 y x

 hi hi x x lo lo

 y x

 lo lo

 y int

 y int y lo

 y lo

 y x

 hi hi

 m y x x act lo lo

 x act x act

 x lo

 x lo

The LOCAL slope evaluated about x act

Engineering/Math/Physics 25: Computational Methods

BMayer@ChabotCollege.edu • ENGR-25_Lec-20_Statistics-2.ppt

32

Bruce Mayer, PE

Linear Interpolation Example

 From the Rockwell Tester Manual

67.3

x lo x hi y lo y hi

 The

Interp

Eqn y int

3 .

5

3 .

0

3 .

5

Engineering/Math/Physics 25: Computational Methods

33

67 .

3

60

70

60

 y int

3 .

135

Bruce Mayer, PE

BMayer@ChabotCollege.edu • ENGR-25_Lec-20_Statistics-2.ppt

Linear Interp With MATLAB

 Use the interp1

Command to find y int

>> Xtab = [60, 70];

% = [xlo, xhi]

>> Ytab = [3.5, 3.0];

% = [ylo, yhi]

>> yint = interp1(Xtab, Ytab,

67.3) yint =

3.1350

 interp2 Does

Linear Interp in 2D zint = interp2(x,y,z,xint,yint)

Used to linearly interpolate a function of two variables: z

 f ( x, y ). Returns a linearly interpolated vector zint at the specified values xint and yint , using (tabular) data stored in x , y , and z .

Engineering/Math/Physics 25: Computational Methods

34

Bruce Mayer, PE

BMayer@ChabotCollege.edu • ENGR-25_Lec-20_Statistics-2.ppt

Inter polation vs Extra polation

 Class Q: Who can Explain the

DIFFERENCE?

 INTERpolation Estimates Data Values between KNOWN Discrete Data Points

• Usually Pretty Good Estimate as we are within the Data “Envelope”

 EXTRApolation PROJECTS Beyond the

Known Data to Predict Additional Values

• Much MORE Uncertainty in Est. value

Engineering/Math/Physics 25: Computational Methods

35

Bruce Mayer, PE

BMayer@ChabotCollege.edu • ENGR-25_Lec-20_Statistics-2.ppt

INterp vs. Extrap Graphically

Extrapolation

Known Data ENDS

Interpolation

Engineering/Math/Physics 25: Computational Methods

36

Bruce Mayer, PE

BMayer@ChabotCollege.edu • ENGR-25_Lec-20_Statistics-2.ppt

Cubic Spline Interpolation

 If the Data exhibits significant

CURVATURE,

MATLAB can

Interpolate with

Curves as well using the spline form yint = spline(x,y,xint)

Linear

Spline Curve

Computes a cubic-spline interpolation where x and y are vectors containing the data and xint is a vector containing the values of the independent variable x at which we wish to estimate the dependent variable y . The result yint is a vector the same size as xint containing the interpolated values of y that correspond to xint

Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE

BMayer@ChabotCollege.edu • ENGR-25_Lec-20_Statistics-2.ppt

37

All Done for Today

Consider the

Source

Engineering/Math/Physics 25: Computational Methods

38

 Most Engineering Data is NOT Sufficiently

ACCURATE nand/nor

PRECISE to Justify

Anything But LINEAR

Interpolation

Bruce Mayer, PE

BMayer@ChabotCollege.edu • ENGR-25_Lec-20_Statistics-2.ppt

Engr/Math/Physics 25

Appendix

2 x

3 

7 x

2 

9 x

6 f

Bruce Mayer, PE

Licensed Electrical & Mechanical Engineer

BMayer@ChabotCollege.edu

Bruce Mayer, PE

BMayer@ChabotCollege.edu • ENGR-25_Lec-20_Statistics-2.ppt

Engineering/Math/Physics 25: Computational Methods

39

Random No. Table

Engineering/Math/Physics 25: Computational Methods

40

Bruce Mayer, PE

BMayer@ChabotCollege.edu • ENGR-25_Lec-20_Statistics-2.ppt

Download