Presentation is loading. Please wait.

Presentation is loading. Please wait.

ENGR-25_Lec-20_Statistics-2.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed.

Similar presentations


Presentation on theme: "ENGR-25_Lec-20_Statistics-2.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed."— Presentation transcript:

1 BMayer@ChabotCollege.edu ENGR-25_Lec-20_Statistics-2.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege.edu Engr/Math/Physics 25 Chp7 Statistics-2

2 BMayer@ChabotCollege.edu ENGR-25_Lec-20_Statistics-2.ppt 2 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods 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

3 BMayer@ChabotCollege.edu ENGR-25_Lec-20_Statistics-2.ppt 3 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods 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

4 BMayer@ChabotCollege.edu ENGR-25_Lec-20_Statistics-2.ppt 4 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods 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 = 68376361) r i+2 = 1601 (r i+1 2 = 14160169) r i+3 = 6320 (r i+2 2 = 2563201)

5 BMayer@ChabotCollege.edu ENGR-25_Lec-20_Statistics-2.ppt 5 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods 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”

6 BMayer@ChabotCollege.edu ENGR-25_Lec-20_Statistics-2.ppt 6 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Random Number Commands

7 BMayer@ChabotCollege.edu ENGR-25_Lec-20_Statistics-2.ppt 7 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Some (psuedo)Random No.s MATLAB Command → RandTab2 = rand(18,8);

8 BMayer@ChabotCollege.edu ENGR-25_Lec-20_Statistics-2.ppt 8 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods 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

9 BMayer@ChabotCollege.edu ENGR-25_Lec-20_Statistics-2.ppt 9 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods 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

10 BMayer@ChabotCollege.edu ENGR-25_Lec-20_Statistics-2.ppt 10 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods 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.

11 BMayer@ChabotCollege.edu ENGR-25_Lec-20_Statistics-2.ppt 11 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods 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

12 BMayer@ChabotCollege.edu ENGR-25_Lec-20_Statistics-2.ppt 12 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods 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

13 BMayer@ChabotCollege.edu ENGR-25_Lec-20_Statistics-2.ppt 13 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Fixed Model Architecture  The Model is assumed to be UNvarying; i.e., it behaves as a Math FUNCTION  Example: SPICE SPICE ≡ Simulation Program with Integrated Circuit Emphasis (UCB)  SPICE has Monte Carlo BUILT-IN  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

14 BMayer@ChabotCollege.edu ENGR-25_Lec-20_Statistics-2.ppt 14 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods 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

15 BMayer@ChabotCollege.edu ENGR-25_Lec-20_Statistics-2.ppt 15 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods 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

16 BMayer@ChabotCollege.edu ENGR-25_Lec-20_Statistics-2.ppt 16 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Scaling rand  rand covers the interval [0,1] – To cover [a,b] SCALE & OFFSET the Random No. Let x be a random No. over [0,1], then a random number y over [a,b] >> y =(37-19)*rand + 19  Example: Use rand to Produce Uniformly Dist Random No over [19,37] >> y =(37-19)*rand + 19 y = 36.1023 >> y =(37-19)*rand + 19 y = 23.1605 Example Result

17 BMayer@ChabotCollege.edu ENGR-25_Lec-20_Statistics-2.ppt 17 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Scaled & Offset Random No.s 33.044528.846230.597724.599820.539319.679319.549720.0731 26.015324.333825.815035.620823.724734.933032.393331.2755 23.350432.404533.608426.743733.418335.439228.000419.7638 26.270422.401228.590922.326719.526033.331327.638620.2860 20.736231.362025.313135.287935.719420.776835.285028.3897 21.375522.303235.902036.635532.146023.713729.977620.7411 35.956925.632734.767026.899727.795025.036430.118033.7267 36.210430.261128.902821.000129.413531.235134.470033.7158 29.353833.044130.204623.645223.271121.458033.498832.0039 20.076020.460329.566826.357027.259331.982129.381021.6976 23.226035.728922.739429.708136.335620.921722.292630.8729 25.356932.962824.422423.719828.842530.767623.318828.3347 33.781527.762227.476629.851228.380427.895134.957236.5135 19.277326.845523.148831.801923.168733.022919.516130.6818 19.774427.042134.197622.991427.800231.870727.818233.4060 22.041824.514322.505821.113530.233135.267022.022727.1684 30.684128.153223.066624.340231.224435.036636.616326.7830 32.171028.193922.072724.738026.119325.014931.828533.8556 30.659433.717323.098026.635025.613931.577428.008520.5025 27.116633.307026.842628.141436.783722.560627.479621.3971 rand1937 = (37- 19)*rand(20,8) + 19 >> Rmax =max(max(rand1937)) Rmax = 36.7837 >> Rmin = min(min(rand1937)) Rmin = 19.2773

18 BMayer@ChabotCollege.edu ENGR-25_Lec-20_Statistics-2.ppt 18 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods 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 =(2.3)*randn - 17  Example: Use randn to Produce Normal Dist with µ = –17 & σ = 2.3 >> w =(2.3)*randn - 17 w = -20.8308 >> w =(2.3)*randn - 17 w = -16.7117 Example Result

19 BMayer@ChabotCollege.edu ENGR-25_Lec-20_Statistics-2.ppt 19 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods rand vs randn – scaled and offset  rand RN100 = 100*rand(10000,1); hist(RN100,100), title('rand')  randn Norm100 = 100*randn(10000,1) + 100 hist(Norm100,100), title('randn')

20 BMayer@ChabotCollege.edu ENGR-25_Lec-20_Statistics-2.ppt 20 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Monte Carlo Example (1)  Build a Wharehouse from PreCast Concrete (a Tilt-Up) Per PERT Chart 1. Project Start 2 3 4567 1. Project End A B C D EFGH  PERT  Program Evaluation and Review Technique A Scheduling Tool Developed for the USA Space Program

21 BMayer@ChabotCollege.edu ENGR-25_Lec-20_Statistics-2.ppt 21 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Monte Carlo Example (2) 1. Project Start 2 3 4567 1. Project End A B C D EFGH  In This Case The Schedule Elements E.Install PreCast Parts on Foundation F.Build Roof G.Finish Interior and Exterior H.Inspect Result A.Excavate Foundation B.Construct Foundation C.Fabricate PreCast Components D.Ship PreCast Parts to Building Site

22 BMayer@ChabotCollege.edu ENGR-25_Lec-20_Statistics-2.ppt 22 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Monte Carlo Example (3)  Task Durations → Normal Random Variables Assume Normally Distributed Task ID Task Description Mean Duration (days) Std Dev (days) A Foundation Excavation 3.5 1 B Pour Foundation 2.5 0.5 C Fab PreCast Elements 5 1 D Ship PreCast Parts 0.5 E Tilt-Up PreCast Parts 5 1.5 F Roofing 2 1 G Finish Work 4 1 Expected Duration = 17 Days

23 BMayer@ChabotCollege.edu ENGR-25_Lec-20_Statistics-2.ppt 23 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods 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 Early GATE

24 BMayer@ChabotCollege.edu ENGR-25_Lec-20_Statistics-2.ppt 24 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Monte Carlo Example (5)  Run-1 µ = 16.27 Days σ = 1.61 Days  See some Negative Durations! May want to Adjust

25 BMayer@ChabotCollege.edu ENGR-25_Lec-20_Statistics-2.ppt 25 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Monte Carlo Example (6)  Run-2 µ = 16.99 Days σ = 2.05 Days

26 BMayer@ChabotCollege.edu ENGR-25_Lec-20_Statistics-2.ppt 26 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Monte Carlo Example (7)  The MATLAB Script File % Bruce Mayer, PE ENGR25 25Oct11 % Normal Dist Task Duration on PERT Chart % file = Monte_Carlo_Wharehouse.m % % 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; 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)

27 BMayer@ChabotCollege.edu ENGR-25_Lec-20_Statistics-2.ppt 27 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Monte Carlo Example (8)  Just for Fun Try 1000 Random Simulation Cycles  µ 1000 = 17.3730 days Expected 17  σ 1000 = 2.1603 days Expected 2.1794 by RMS calc 1. Project Start 2 3 4567 1. Project End A B C D EFGH

28 BMayer@ChabotCollege.edu ENGR-25_Lec-20_Statistics-2.ppt 28 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods 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

29 BMayer@ChabotCollege.edu ENGR-25_Lec-20_Statistics-2.ppt 29 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods 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

30 BMayer@ChabotCollege.edu ENGR-25_Lec-20_Statistics-2.ppt 30 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Linear Interpolation (3)  Then the Linear Interpolation Eqn  A Proportionality, Where x act  actual MEASURED value x lo  TABULATED Value Just Below x act x hi  TABULATED Value Just Above x act y int  Unknown INTERPOLATED value y lo  TABULATED Value Corresponding to x lo y hi  TABULATED Value Corresponding to x hi

31 BMayer@ChabotCollege.edu ENGR-25_Lec-20_Statistics-2.ppt 31 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Linear InTerp PorPortionality ii.e.; y int −y lo is to y hi −y lo AS x act −x lo is to x hi −x lo

32 BMayer@ChabotCollege.edu ENGR-25_Lec-20_Statistics-2.ppt 32 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods InTerp  Pt-Slope Line Eqn  It’s LINEAR as the Interp Eqn can be cast into the familiar Point-Slope Eqn  ReWorking the Interp Equation The LOCAL slope evaluated about x act

33 BMayer@ChabotCollege.edu ENGR-25_Lec-20_Statistics-2.ppt 33 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Linear Interpolation Example  From the Rockwell Tester Manual 67.3 x lo x hi y hi y lo TThe Interp Eqn

34 BMayer@ChabotCollege.edu ENGR-25_Lec-20_Statistics-2.ppt 34 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods 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 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. zint = interp2(x,y,z,xint,yint)  interp2 Does Linear Interp in 2D

35 BMayer@ChabotCollege.edu ENGR-25_Lec-20_Statistics-2.ppt 35 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Interpolation vs Extrapolation  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

36 BMayer@ChabotCollege.edu ENGR-25_Lec-20_Statistics-2.ppt 36 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods INterp vs. Extrap Graphically Interpolation Extrapolation Known Data ENDS

37 BMayer@ChabotCollege.edu ENGR-25_Lec-20_Statistics-2.ppt 37 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Cubic Spline Interpolation  If the Data exhibits significant CURVATURE, MATLAB can Interpolate with Curves as well using the spline form Linear Spline Curve yint = spline(x,y,xint) 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

38 BMayer@ChabotCollege.edu ENGR-25_Lec-20_Statistics-2.ppt 38 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods All Done for Today Consider the Source  Most Engineering Data is NOT Sufficiently ACCURATE nand/nor PRECISE to Justify Anything But LINEAR Interpolation

39 BMayer@ChabotCollege.edu ENGR-25_Lec-20_Statistics-2.ppt 39 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege.edu Engr/Math/Physics 25 Appendix

40 BMayer@ChabotCollege.edu ENGR-25_Lec-20_Statistics-2.ppt 40 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Random No. Table


Download ppt "ENGR-25_Lec-20_Statistics-2.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed."

Similar presentations


Ads by Google