1 / 37

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

Chabot Mathematics. §7.4 Least Squares Regression. Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege.edu. 7.3. Review §. Any QUESTIONS About §7.3 → Optimization of 2-Variable Functions Any QUESTIONS About HomeWork §7.3 → HW-05. §7.4 Learning Goals.

peggy
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. Chabot Mathematics §7.4 LeastSquares Regression Bruce Mayer, PE Licensed Electrical & Mechanical EngineerBMayer@ChabotCollege.edu

  2. 7.3 Review § • Any QUESTIONS About • §7.3 → Optimization of 2-Variable Functions • Any QUESTIONS About HomeWork • §7.3 → HW-05

  3. §7.4 Learning Goals • Explore least-squares approximation of data as an optimization problem involving a function of two variables • Examine several applied problems using least-squares approximation of data • Discuss nonlinear curve-fitting techniques using least-squares approximation

  4. Scatter on plots on XY-Plane • A scatter plot usually shows how an EXPLANATORY, or Independent, variable affects a RESPONSE, or Dependent Variable • Sometimes the SHAPE of the scatter reveals a relationship • Shown Below is a Conceptual Scatter plot that could Relate the RESPONSE to some EXCITITATION

  5. Linear Fit by Guessing • The previous plot looks sort of Linear • We could use a Ruler to draw a y = mx+bline thru the data • But • which Line is BETTER? • and WHY?

  6. Many Software programs Calculate “fitted” Values of m & b How does the Software Make these Calcs? How Good is the fitted Line Compared to the Data? Most automated curve fitters, use the “Least Squares” Criterion Least Squares Curve Fitting

  7. To make a Good Fit, MINIMIZE the |GUESS − data|distance by one of Least Squares Best Guess-y data Best Guess-x

  8. Least Squares Minimziation • To Minimize J take Simultaneously • The above produces Two Eqns in the Two UnKnown “Fitting” Parameters, m0& b0

  9. It is Typical to Minimize the VERTICAL distances; i.e.: Least Squares cont • Note that The Function J contains two Variables; m & b • Recall from the previous text sections that to MINIMIZE a Function of 2-Vars set the 1st partial Derivatives equal to Zero

  10. The Distance from The Best-Fit Line to the Actual Data Point is called the RESIDUAL For the Vertical Distance the Residual is just δy Goodness of Fit • If the Sum of the Residuals were ZERO, then the Line would Fit Perfectly • Thus J, afterfinding m & b, is an Indication of the Goodness of Fit

  11. Now J is an indication of Fit, but we Might want to SCALE it relative to the MAGNITUDE of the Data For example consider DataSet1 with x&y values in the MILLIONS DataSet2 with x&y values in the single digits Goodness of Fit cont • In this case we would expect J1 >> J2 • To remove the affect of Absolute Magnitude, Scale J against the Data Set mean; e.g • mean1 = 730 000 • mean2 = 4.91

  12. The Mean-Scaling Quantity is the Actual-Data Relative to the Actual-Mean Goodness of Fit cont • Finally the Scaled Fit-Metric, “r-squared’ • As before the Squaring Ensures that all Terms in the sum are POSITIVE

  13. The r2 Value is Also Called the COEFFICIENT OF DETERMINATION r2 = Coeff of Determination • J  Sum of Residual (errors) • May be Zero or Positive • S  Data-to-Mean Scaling Factor • Always Positive if >1 Data-Pt and data not “perfectly Horizontal” • If J = 0, then there is NO Distance Between the calculated Line and Data • Thus if J = 0, then r2 = 1; so r2 = 1 (or 100%)indicates a PERFECT FIT

  14. The COEFFICIENT OF DETERMINATION Meaning of r2 • Has This Meaning The coefficient of determination tells you what proportion of the variation between the data points is explained or accounted for by the best line fitted to the points. It indicates how close the points are to the line.

  15. WhiteBoard Derivation LinearRegressExpress MTH16_Lec-07a_sec_7-4_Linear-Regression_Least-Squares_Tutorial.pptx

  16. Example  Least Squares Cp • The following data was recorded in an experiment which measured the variation of the specific heat of a chemical with temperature. • It is expected that the specific heat (Cp) should depend linearly on the temperature, T

  17. Example  Least Squares Cp • For this situation • Plot the data on a scatter Graph • Fit a straight line to the data by eye; find the slope and intercept of this line; write an equation for this line. • Perform a linear regression analysis on the Cp data. Write an equation for this line • Use the Regression Line Equation to Estimate the specific heat of this chemical when the temperature is 75 & 115 °C.

  18. Example  Least Squares Cp • SOLUTION: • The scatter diagram shows each datum plotted with Cp on the Y-axis, the Temperature plotted on the X-Axis • Now employ software (MATLAB or Excel), or a calculation by hand, to compute the CoEfficientsof the Least-Squares Regression Line.

  19. Cp Scatter Plot

  20. CpEyeBall & Regression Plots By Regression

  21. CpInterp & Extrap by Regression • Using the Regression Equation • Interpolate WithIn the Known Data • At 75 °C find Cp≈ 1.6808 J/(mol•°C) • Extrapolate OutSide the Known Data • At 115 °C find Cp≈ 1.7705 J/(mol•°C) • Note that Interpolation is generally much more reliable than Extrapolation

  22. The Significance of ANY Data Set Can be Improved by Normalizing Normalize  Scale Data such that the Values run: 0 →1 0% → 100% Steps to Normalization Find the MAX & MIN values in the Data Set; e.g., zmax & zmin Calculate the Data Range, RD RD = (zmax – zmin) Calc the Individual Data Differences Relative to the MIN Δzk = zk - zmin Data Scaling - Normalization

  23. Finally, Scale the Δzk relative to RD Ψk = Δzk /RD Scale the corresponding “y” values in the Same Manner to produce say, Φk Plot Φk vs Ψk on x & y scales that Run from 0→1 Example– Do Frogs Croak More on WARM Nites? Data Scaling – Normailzation cont

  24. Normalize T → Θ CPH → Ω Normalization Example • Now Compare Plots • CPH vs T • Ω vs Θ

  25. T-CPH Plot Ω-Θ Plot Plots Compared • The Θ-Ω Plot Fully Utilizes Both Axes

  26. Use MATLAB’s AutoMatic Fitting Utility to Find The Best Line for the the Frog Croaking Data Basic Fitting Time For Live Demo SEE: Demo_Frog_Croak_BasicFit_1110.m

  27. WhiteBoard Work • No Problems From §7.4 • Did Regression Derivation Instead

  28. All Done for Today m0 =0b0 = yavg

  29. Chabot Mathematics Appendix Do On Wht/BlkBorad Bruce Mayer, PE Licensed Electrical & Mechanical EngineerBMayer@ChabotCollege.edu –

  30. P7.1-47 Skin Surface Area • Skin Area Formula based on easy to perform Measurements • Where • S ≡ Surface Area in sq-meters • W ≡ Person’s mass in kg • H ≡ Height in CentiMeters (cm) • Make Contour Plot S(W,H), and find Height for W=18.37kg & S=0.048m2

  31. S(15.8kg,87.11cm) • By MuPad • S := 0.0072*(W^0.425)*(H^0.725) • Sa = subs(S,W=15.83,H=87.11) • In Sq-Meters

  32. Basal Metabolism • The Harris-Benedict Power Eqns for Energy per Day in kgCalories • Human Males • Human Females • h ≡ hgt in cm, A ≡ in yrs, w ≡ weight in kg

  33. Basal Metabolism • Find • Ba := subs(Bm, w=90,h=190,A=22 • Find • Bb := subs(Bf, w=61,h=170,A=27)d

  34. Basal Metabolism • Find • Ac := subs(Am, wm=85, hm=193, Bmm=2108) • Find • Ad := subs(Af, wf=67, hf=173, Bff=1504)

More Related