1 / 40

Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege

Engr/Math/Physics 25. Chp7 Statistics-2. Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege.edu. Learning Goals. Create HISTOGRAM Plots Use MATLAB to solve Problems in Statistics Probability Use Monte Carlo (random) Methods to Simulate Random processes

ayala
Télécharger la présentation

Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Engr/Math/Physics 25 Chp7Statistics-2 Bruce Mayer, PE Licensed Electrical & Mechanical EngineerBMayer@ChabotCollege.edu

  2. 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. 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. 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 • ri= 8269 • ri+1 = 3763 (ri2 = 68376361) • ri+2 = 1601 (ri+12 = 14160169) • ri+3= 6320 (ri+22 = 2563201)

  5. 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. Random Number Commands

  7. Some (psuedo)Random No.s MATLAB Command → RandTab2 = rand(18,8);

  8. 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. 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. 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. Monte Carlo Process Steps • Define the System • Generate (psuedo)Random No.s • Generate Random VARIABLES • Usually Involves SCALING and/or OFFSETTING the RNs • Evaluate the Model N-Times; each time using Different Random Vars • Statistical Analysis of the N-trial Results to assess Validity & Values

  12. 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. 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. Monte Carlo Summarized • Monte Carlo Method: Probabilistic simulation technique used when a process has a random component • Identify a Probability Distribution Function (PDF) • Setup intervals of random numbers to match probability distribution • Obtain the random numbers • Interpret the results

  15. MATLAB rand command produces RNs with a Uniform Distribution i.e., ANY Value over [0,1] just as likely as Any OTHER MATLAB RANDOM No. PDFs • MATLAB randn, by Contrast, produces a NORMAL Distribution • i.e., The MIDDLE Value is MORE Likely than any other

  16. 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] Scaling rand • 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

  17. Scaled & Offset Random No.s rand1937 = (37-19)*rand(20,8) + 19 >> Rmax =max(max(rand1937)) Rmax= 36.7837 >> Rmin = min(min(rand1937)) Rmin= 19.2773

  18. 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 Scaling randn • 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

  19. rand rand vs randn – scaled and offset • randn RN100 = 100*rand(10000,1); hist(RN100,100), title('rand') Norm100 = 100*randn(10000,1) + 100 hist(Norm100,100), title('randn')

  20. 2 1. Project Start 1. Project End 4 5 6 7 3 Monte Carlo Example (1) • Build a Wharehouse from PreCast Concrete (a Tilt-Up) Per PERT Chart A B E F G H D C • PERT  Program Evaluation and Review Technique • A Scheduling Tool Developed for the USA Space Program

  21. 2 1. Project Start 1. Project End 4 5 6 7 3 Monte Carlo Example (2) A B E F G H D C • In This Case The Schedule Elements • Install PreCast Parts on Foundation • Build Roof • Finish Interior and Exterior • Inspect Result • Excavate Foundation • Construct Foundation • Fabricate PreCast Components • Ship PreCast Parts to Building Site

  22. Monte Carlo Example (3) • Task Durations → Normal Random Variables • Assume Normally Distributed

  23. 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. Monte Carlo Example (5) • Run-1 • µ = 16.27 Days • σ = 1.61Days • See some Negative Durations! • May want to Adjust

  25. Monte Carlo Example (6) • Run-2 • µ = 16.99 Days • σ = 2.05Days

  26. The MATLAB Script File Monte Carlo Example (7) % 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. 2 1. Project Start 1. Project End 4 5 6 7 3 Monte Carlo Example (8) • Just for Fun Try 1000 Random Simulation Cycles A B E F G H D C • µ1000 = 17.3730 days • Expected 17 • σ1000 = 2.1603 days • Expected 2.1794 by RMS calc Q.E.F.

  28. 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. 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. Linear Interpolation (3) • Then the Linear Interpolation Eqn • A Proportionality, Where • xact actual MEASURED value • xlo TABULATED Value Just Below xact • xhi TABULATED Value Just Above xact • yint Unknown INTERPOLATED value • ylo TABULATED Value Corresponding to xlo • yhi TABULATED Value Corresponding to xhi

  31. Linear InTerpPorPortionality • i.e.; yint−ylo is to yhi−yloAS xact−xlo is to xhi−xlo

  32. 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 xact

  33. Linear Interpolation Example • From the Rockwell Tester Manual ylo xlo 67.3 yhi xhi • The InterpEqn

  34. Use the interp1 Command to find yint Linear Interp With MATLAB • interp2 Does Linear Interp in 2D >> Xtab = [60, 70]; % = [xlo, xhi] >> Ytab = [3.5, 3.0]; % = [ylo, yhi] >> yint = interp1(Xtab, Ytab, 67.3) yint = 3.1350 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.

  35. Interpolation vsExtrapolation • 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. INterp vs. Extrap Graphically Extrapolation Known Data ENDS Interpolation

  37. If the Data exhibits significant CURVATURE, MATLAB can Interpolate with Curves as well using the spline form Cubic Spline Interpolation 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. All Done for Today ConsidertheSource • Most Engineering Data is NOT Sufficiently ACCURATE nand/nor PRECISE to Justify Anything But LINEAR Interpolation

  39. Engr/Math/Physics 25 Appendix Time For Live Demo Bruce Mayer, PE Licensed Electrical & Mechanical EngineerBMayer@ChabotCollege.edu

  40. Random No. Table

More Related