Python Analysis. PHYS 224 October 1/2, 2015

Size: px
Start display at page:

Download "Python Analysis. PHYS 224 October 1/2, 2015"

Transcription

1 Python Analysis PHYS 224 October 1/2, 2015

2 Goals Two things to teach in this lecture 1. How to use python to fit data 2. How to interpret what python gives you Some references: ScipyScriptRepo/CurveFitting.ipynb 2

3 Fitting Experimental Data The goal of the lab experiments is to determine a physical quantity y (dependent variable) as a function of x (independent variable) How? Measure the pair (x i,y i ) a number (N) times Find a fit function y=y(x) that describes the relationship between these two quantities 3

4 The Linear Case The simplest function relating the two variables is the linear function f(x) = y = ax +b This is valid for any yi,xi combination If a and b are known, the true value of yi can be calculated for any xi yi,true = axi + b 4

5 Linear Regression Linear regression calculates the most probable values of a and b such that the linear equation is valid yi,true = axi + b When taking measurements of yi, these usually obey Gauss distribution 5

6 An Example Ideal Gas Law: P*V = n*r*t Pressure * Volume = n * R * Temperature P = [(n*r)/v]*t 6

7 Fitting in Python We re going to use the curve_fit function, which is part of the scipy.optimize package The usage is as follows: fit_parameters,fit_covariance = scipy.optimize.curve_fit(fit_function,x_data,y_data,sigma,guess) #fit_parameters - an array of the output fit parameters #fit_covariance - an array of the covariance of the output fit parameters #fit_function - the function used to do the fit #sigma - the uncertainty associated with the data #guess - the initial guess input to the fit 7

8 Fitting with curve_fit import numpy import scipy.optimize from matplotlib import peplos #define the function to be used in the fitting def linearfit(x,*p): return p[0]+p[1]*x #read in the data (currently only located on my hard drive...) temp_data, vol_data = numpy.loadtxt('ideal_gas_law.txt',unpack=true) #add an uncertainty to each measurement point uncertainty = numpy.empty(len(vol_data)) uncertainty.fill(20.) #do the fit fit_parameters,fit_covariance = scipy.optimize.curve_fit(linearfit, temp_data, vol_data, p0=(1.0,8.0),sigma=uncertainty) 8

9 } Fitting with curve_fit import numpy import scipy.optimize from matplotlib import peplos #define the function to be used in the fitting def linearfit(x,*p): return p[0]+p[1]*x #read in the data (currently only located on my hard drive...) temp_data, vol_data = numpy.loadtxt('ideal_gas_law.txt',unpack=true) #add an uncertainty to each measurement point uncertainty = numpy.empty(len(vol_data)) uncertainty.fill(20.) Function #do the fit fit_parameters,fit_covariance = scipy.optimize.curve_fit(linearfit, temp_data, vol_data, p0=(1.0,8.0),sigma=uncertainty) X data } Initial guess for parameters } Uncertainty on data } } Y data 9

10 Results fit parameters =[ ] fit covariance =[[ e e + 01] [ e e 01]] So what does this mean? We set up the function for the fit to be: y = p[0] + p[1]*x So with the fit parameters, the function is: y = *x 10

11 How did it do this? The function curve_fit uses a minimizer This varies the fit parameters ( p[0] and p[1] ) to see what value of these are most likely to fit the data properly This also depends on residuals, which are the difference between the result of the fit and the data at each point We ll discuss the quantity which is minimized in a bit 11

12 Probability The probability of any one point being from the fit is P a,b (y) = 1 p e 2 y (y a bx) y Where y is the measured data, a and b are from the fit 12

13 Full Probability For a set of N measurements of the dependent variable y y1, y2, y3, yn The probability of obtaining these values is the product of the individual probabilities P a,b (y 1,y 2,y 3...y N )=P a,b (y 1 )P a,b (y 2 )P a,b (y 3 )...P a,b (y N ) = 1 N y e P Ni=1 (y i a bx i ) 2 2 y 2 13

14 Full Probability For a set of N measurements of the dependent variable y y1, y2, y3, yn The probability of obtaining these values is the product of the individual probabilities P a,b (y 1,y 2,y 3...y N )=P a,b (y 1 )P a,b (y 2 )P a,b (y 3 )...P a,b (y N ) = 1 N y e P Ni=1 (y i a bx i ) 2 2 y 2 Called the chi-squared (χ 2 ) 14

15 Chi-Squared 2 = NX i=1 (y i a bx i ) 2 2 y The circled part is the definition of the residuals, ie the true data (y i ) minus the fit data (a + b*x i ) Dividing this by the standard deviation (σ) tells us how many standard deviations the test data is away from the fit at that x The square ensures this is always positive 15

16 Plotting the Residuals #read in the data (currently only located on my hard drive...) temp_data,vol_data = numpy.loadtxt('/users/kclark/desktop/teaching/phys224/weather_data/ ideal_gas_law.txt',unpack=true) #add an uncertainty to each measurement point uncertainty = numpy.empty(len(vol_data)) uncertainty.fill(20.) #do the fit fit_parameters,fit_covariance = scipy.optimize.curve_fit(linearfit,temp_data,vol_data,p0=(1.0,8.0),sigma=uncertainty) #now generate the line of the best fit #set up the temperature points for the full array fit_temp = numpy.arange(270,355,5) #make the data for the best fit values fit_answer = linearfit(fit_temp,*fit_parameters) #calculate the residuals fit_resid = vol_data-linearfit(temp_data,*fit_parameters) #make a line at zero zero_line = numpy.zeros(len(vol_data)) 16

17 How do the Residuals Look? The residuals are obviously a large component of the χ 2 value used by the minimizer They can be plotted to look for trends and see if the fit function is appropriate 17

18 Other Results from curve_fit curve_fit returns not only the best values for the parameters p[0] and p[1] The fit covariance matrix is also returned One strength of curve_fit is the ease of use of the fit covariance matrix 18

19 Interpreting the Covariance Matrix fit parameters =[ ] fit covariance =[[ e e + 01] [ e e 01]] Diagonal elements are the square of the standard deviation for that parameter The non-diagonal elements show the relationship between the parameters cov(x, y) = 1 N NX (x i x)(y i ȳ) i=1 19

20 Fit Results import numpy import scipy.optimize from matplotlib import pyplot #define the function to be used in the fitting, which is linear in this case def linearfit(x,*p): return p[0]+p[1]*x #read in the data (currently only located on my hard drive...) temp_data,vol_data = numpy.loadtxt('/users/kclark/desktop/teaching/phys224/weather_data/ ideal_gas_law.txt',unpack=true) #add an uncertainty to each measurement point uncertainty = numpy.empty(len(vol_data)) uncertainty.fill(20.) #do the fit fit_parameters,fit_covariance = scipy.optimize.curve_fit(linearfit,temp_data,vol_data,p0=(1.0,8.0),sigma=uncertainty) #determine the standard deviations for each parameter sigma0 = numpy.sqrt(fit_covariance[0,0]) sigma1 = numpy.sqrt(fit_covariance[1,1]) 20

21 Fit Results #do the fit fit_parameters,fit_covariance = scipy.optimize.curve_fit(linearfit,temp_data,vol_data,p0=(1.0,8.0),sigma=uncertainty) #determine the standard deviations for each parameter sigma0 = numpy.sqrt(fit_covariance[0,0]) sigma1 = numpy.sqrt(fit_covariance[1,1]) #calculate the mean fit result to plot the line fit_line = linearfit(temp_data,*fit_parameters) #calculate the residuals fit_residuals = vol_data - fit_line #calculate the data for the best fit minus one sigma in parameter #1 params_minus1sigma = numpy.array([fit_parameters[0],fit_parameters[1]-sigma1]) data_minus1sigma = linearfit(temp_data,*params_minus1sigma) #do some plotting of the results pyplot.errorbar(temp_data,vol_data,yerr=uncertainty,marker='o',ls='none') pyplot.plot(fit_temp,fit_answer,'b--') pyplot.plot(temp_data,data_plus1sigma,'g--',temp_data,data_minus1sigma,'g--') pyplot.title("ideal Gas Law Example") pyplot.xlabel("temperature (K)") pyplot.ylabel("pressure (Pa)") 21

22 Fit Results fit parameters =[ ] fit covariance =[[ e e + 01] [ e e 01]] Calculate the standard deviation on the slope (p[1]) This is the square root of the [1,1] entry of the covariance matrix 22

23 Fit Results fit parameters =[ ] fit covariance =[[ e e + 01] [ e e 01]] Show the p[1] parameter with the standard deviation: p1 = 8.33 ±

24 Comparison to Accepted Values We obtained the result p[1] = 8.33±0.47 We assume that there is 1 mole in a 1m 3 volume so that n=v=1 The accepted value (currently) is ± The accepted value IS contained within our uncertainty (our one sigma range is from 7.86 to 8.80) These values agree within their error 24

25 Application to Non-linear Examples This method can also be applied to other examples Powers: y = b x can be linearized as y 2 = b 2 *x Polynomials: y = a + b*x + c*x 2 + d*x 3 This is just a case of using multiple regression since the equation is linear in the coefficients Exponentials: y= a*e bx Can be linearized as ln(y) = ln(a) + b*x There are many other examples 25

26 Return to Chi-Squared 2 = NX i=1 (y i y(x i )) 2 2 y Here the definition of the residual has changed Instead of y i - a - b*x i a more general term has been used y i is still the data y(x i ) is the fit function evaluated at x i 26

27 Gauss Distribution The probability is described by P (x) = 1 p 2 e (x x)2 2 2 where the average (mean) value is x and the spread in values is σ 27

28 Gauss Distribution We use the probabilities shown above to determine how probable a value is in this distribution When we take a measurement, we expect that 68.2% of the time it will be within 1σ from the mean value Another way of phrasing this is that we expect a value to be more than 3σ above the mean value only 0.1% of the time 28

29 Another example 29

30 Fitting the Gaussian import numpy import scipy.optimize import matplotlib.pyplot as pyplot import pylab as py #define the function to be used in the fitting, which is linear in this case def gaussfit(x,*p): return p[0]+p[1]*numpy.exp(-1*(x-p[2])**2/(2*p[3]**2)) #read in the data (currently only located on my hard drive...) day_num,rain_data = numpy.loadtxt('/users/kclark/desktop/teaching/phys224/weather_data/ precip_2013.txt', unpack=true) #get some (pretty good) guesses for the fitting parameters data_mean = rain_data.mean() data_std = rain_data.std() #set up the histogram so that it can be fit data_plot = py.hist(rain_data,range=(0.1,90),bins=100) histx = [0.5 * (data_plot[1][i] + data_plot[1][i + 1]) for i in xrange(100)] histy = data_plot[0] #actually do the fitting fit_parameters,fit_covariance = scipy.optimize.curve_fit(gaussfit,histx,histy,p0=(5.0,10.0,data_mean,data_std)) 30

31 Another example Mean Fit mean: 7.06mm Fit standard deviation: 10.13mm } Standard Deviation 31

32 Another example Mean Fit mean: 7.06mm Fit standard deviation: 10.13mm } Standard Deviation 32

33 Another example Mean Fit mean: 7.06mm Fit standard deviation: 10.13mm } Standard Deviation 33

34 Another example Mean Fit mean: 7.06mm Fit standard deviation: 10.13mm Rainfall of 85.5mm is 7.74 standard deviations above the mean (from this data) which is extremely } Standard Deviation unlikely 34

35 Chi-Squared and Goodness of Fit 2 = NX i=1 (y i y(x i )) 2 2 y This can then be used as a goodness of fit test If the function is a good approximation, then the residual will be within one standard deviation, so this will sum to approximately N 35

36 Chi-Squared 2 = NX i=1 (y i y(x i )) 2 2 y We normally use the number of degrees of freedom of the experiment to determine the fit quality The number of DOF is the number of data points in the sample minus the number of parameters in the fit For a sample with 20 data points and a linear fit (2 parameters), DOF = 18 This is used as the goodness of fit since χ 2 /DOF 1 for a good fit 36

37 Revisit the First Example import numpy import scipy.optimize from matplotlib import pyplot #define the function to be used in the fitting, which is linear in this case def linearfit(x,*p): return p[0]+p[1]*x #read in the data (currently only located on my hard drive...) temp_data,vol_data = numpy.loadtxt('/users/kclark/desktop/teaching/phys224/weather_data/ ideal_gas_law.txt',unpack=true) #add an uncertainty to each measurement point uncertainty = numpy.empty(len(vol_data)) uncertainty.fill(20.) #do the fit fit_parameters,fit_covariance = scipy.optimize.curve_fit(linearfit,temp_data,vol_data,p0=(1.0,8.0),sigma=uncertainty) #calculate the chi-squared value chisq = sum(((vol_data-linearfit(temp_data,*fit_parameters))/uncertainty)**2) print chisq dof = len(temp_data)-len(fit_parameters) print dof 37

38 Revisit the First Example Is this a good fit? 2 = X16 i=1 apple presdatai fit i uncertainty 2 = 65.6 Divide this by the DOF We have 16 data points, 2 parameters 2 DOF = =4.68 This may not be a great fit... 38

39 Goodness of Fit Previous statements only mostly true More accurately: χ 2 >> 1 is a very poor fit, maybe even a fit model which doesn t match χ 2 > 1 is not a good fit, or the uncertainty is underestimated χ 2 << 1 means the uncertainty could be overestimated 39

40 Summary You should now be well prepared to use python to fit the data Your practice with this starts with the next pendulum exercise, which you can begin now! 40

Python Analysis. PHYS 224 September 25/26, 2014

Python Analysis. PHYS 224 September 25/26, 2014 Python Analysis PHYS 224 September 25/26, 2014 Goals Two things to teach in this lecture 1. How to use python to fit data 2. How to interpret what python gives you Some references: http://nbviewer.ipython.org/url/media.usm.maine.edu/~pauln/

More information

Parameter Estimation and Fitting to Data

Parameter Estimation and Fitting to Data Parameter Estimation and Fitting to Data Parameter estimation Maximum likelihood Least squares Goodness-of-fit Examples Elton S. Smith, Jefferson Lab 1 Parameter estimation Properties of estimators 3 An

More information

Intermediate Lab PHYS 3870

Intermediate Lab PHYS 3870 Intermediate Lab PHYS 3870 Lecture 4 Comparing Data and Models Quantitatively Linear Regression Introduction Section 0 Lecture 1 Slide 1 References: Taylor Ch. 8 and 9 Also refer to Glossary of Important

More information

Correlation 1. December 4, HMS, 2017, v1.1

Correlation 1. December 4, HMS, 2017, v1.1 Correlation 1 December 4, 2017 1 HMS, 2017, v1.1 Chapter References Diez: Chapter 7 Navidi, Chapter 7 I don t expect you to learn the proofs what will follow. Chapter References 2 Correlation The sample

More information

Unions of Solutions. Unions. Unions of solutions

Unions of Solutions. Unions. Unions of solutions Unions of Solutions We ll begin this chapter by discussing unions of sets. Then we ll focus our attention on unions of sets that are solutions of polynomial equations. Unions If B is a set, and if C is

More information

Computational Physics

Computational Physics Interpolation, Extrapolation & Polynomial Approximation Lectures based on course notes by Pablo Laguna and Kostas Kokkotas revamped by Deirdre Shoemaker Spring 2014 Introduction In many cases, a function

More information

Legendre s Equation. PHYS Southern Illinois University. October 18, 2016

Legendre s Equation. PHYS Southern Illinois University. October 18, 2016 Legendre s Equation PHYS 500 - Southern Illinois University October 18, 2016 PHYS 500 - Southern Illinois University Legendre s Equation October 18, 2016 1 / 11 Legendre s Equation Recall We are trying

More information

Introduction to least square fits for Geant 4 Simulation and ROOT Analysis of a Silicon Beam Telescope Mar , DESY Hamburg Olaf Behnke, DESY

Introduction to least square fits for Geant 4 Simulation and ROOT Analysis of a Silicon Beam Telescope Mar , DESY Hamburg Olaf Behnke, DESY Introduction to least square fits for Geant 4 Simulation and ROOT Analysis of a Silicon Beam Telescope Mar 4-6 2, DESY Hamburg Olaf Behnke, DESY Literature: Roger Barlow: Statistics, A Guide To The Use

More information

Introduction to Determining Power Law Relationships

Introduction to Determining Power Law Relationships 1 Goal Introduction to Determining Power Law Relationships Content Discussion and Activities PHYS 104L The goal of this week s activities is to expand on a foundational understanding and comfort in modeling

More information

CURVE FITTING LEAST SQUARE LINE. Consider the class of linear function of the form. = Ax+ B...(1)

CURVE FITTING LEAST SQUARE LINE. Consider the class of linear function of the form. = Ax+ B...(1) CURVE FITTIG LEAST SQUARE LIE Consider the class of linear function of the form y = f( x) = B...() In previous chapter we saw how to construct a polynomial that passes through a set of points. If all numerical

More information

MA 1128: Lecture 19 4/20/2018. Quadratic Formula Solving Equations with Graphs

MA 1128: Lecture 19 4/20/2018. Quadratic Formula Solving Equations with Graphs MA 1128: Lecture 19 4/20/2018 Quadratic Formula Solving Equations with Graphs 1 Completing-the-Square Formula One thing you may have noticed when you were completing the square was that you followed the

More information

6x 2 8x + 5 ) = 12x 8

6x 2 8x + 5 ) = 12x 8 Example. If f(x) = x 3 4x + 5x + 1, then f (x) = 6x 8x + 5 Observation: f (x) is also a differentiable function... d dx ( f (x) ) = d dx ( 6x 8x + 5 ) = 1x 8 The derivative of f (x) is called the second

More information

The minimal polynomial

The minimal polynomial The minimal polynomial Michael H Mertens October 22, 2015 Introduction In these short notes we explain some of the important features of the minimal polynomial of a square matrix A and recall some basic

More information

Statistical Methods in Particle Physics

Statistical Methods in Particle Physics Statistical Methods in Particle Physics Lecture 3 October 29, 2012 Silvia Masciocchi, GSI Darmstadt s.masciocchi@gsi.de Winter Semester 2012 / 13 Outline Reminder: Probability density function Cumulative

More information

Statistics, Data Analysis, and Simulation SS 2015

Statistics, Data Analysis, and Simulation SS 2015 Statistics, Data Analysis, and Simulation SS 2015 08.128.730 Statistik, Datenanalyse und Simulation Dr. Michael O. Distler Mainz, 27. April 2015 Dr. Michael O. Distler

More information

Regression and Nonlinear Axes

Regression and Nonlinear Axes Introduction to Chemical Engineering Calculations Lecture 2. What is regression analysis? A technique for modeling and analyzing the relationship between 2 or more variables. Usually, 1 variable is designated

More information

Numpy. Luis Pedro Coelho. October 22, Programming for Scientists. Luis Pedro Coelho (Programming for Scientists) Numpy October 22, 2012 (1 / 26)

Numpy. Luis Pedro Coelho. October 22, Programming for Scientists. Luis Pedro Coelho (Programming for Scientists) Numpy October 22, 2012 (1 / 26) Numpy Luis Pedro Coelho Programming for Scientists October 22, 2012 Luis Pedro Coelho (Programming for Scientists) Numpy October 22, 2012 (1 / 26) Historical Numeric (1995) Numarray (for large arrays)

More information

Lecture 10 Polynomial interpolation

Lecture 10 Polynomial interpolation Lecture 10 Polynomial interpolation Weinan E 1,2 and Tiejun Li 2 1 Department of Mathematics, Princeton University, weinan@princeton.edu 2 School of Mathematical Sciences, Peking University, tieli@pku.edu.cn

More information

Simple Linear Regression for the Climate Data

Simple Linear Regression for the Climate Data Prediction Prediction Interval Temperature 0.2 0.0 0.2 0.4 0.6 0.8 320 340 360 380 CO 2 Simple Linear Regression for the Climate Data What do we do with the data? y i = Temperature of i th Year x i =CO

More information

Physics 1140 Fall 2013 Introduction to Experimental Physics

Physics 1140 Fall 2013 Introduction to Experimental Physics Physics 1140 Fall 2013 Introduction to Experimental Physics Joanna Atkin Lecture 5: Recap of Error Propagation and Gaussian Statistics Graphs and linear fitting Experimental analysis Typically make repeat

More information

Least-Squares Regression

Least-Squares Regression Least-quares Regression ChEn 2450 Concept: Given data points (x i, ), find parameters in the function f(x) that minimize the error between f(x i ) and. f(x) f(x) x x Regression.key - eptember 22, 204 Introduction:

More information

Complex Numbers. A complex number z = x + iy can be written in polar coordinates as re i where

Complex Numbers. A complex number z = x + iy can be written in polar coordinates as re i where Lab 20 Complex Numbers Lab Objective: Create visualizations of complex functions. Visually estimate their zeros and poles, and gain intuition about their behavior in the complex plane. Representations

More information

Some Statistics. V. Lindberg. May 16, 2007

Some Statistics. V. Lindberg. May 16, 2007 Some Statistics V. Lindberg May 16, 2007 1 Go here for full details An excellent reference written by physicists with sample programs available is Data Reduction and Error Analysis for the Physical Sciences,

More information

Lecture 3: Linear Models. Bruce Walsh lecture notes Uppsala EQG course version 28 Jan 2012

Lecture 3: Linear Models. Bruce Walsh lecture notes Uppsala EQG course version 28 Jan 2012 Lecture 3: Linear Models Bruce Walsh lecture notes Uppsala EQG course version 28 Jan 2012 1 Quick Review of the Major Points The general linear model can be written as y = X! + e y = vector of observed

More information

Statistics for Data Analysis. Niklaus Berger. PSI Practical Course Physics Institute, University of Heidelberg

Statistics for Data Analysis. Niklaus Berger. PSI Practical Course Physics Institute, University of Heidelberg Statistics for Data Analysis PSI Practical Course 2014 Niklaus Berger Physics Institute, University of Heidelberg Overview You are going to perform a data analysis: Compare measured distributions to theoretical

More information

Cheng Soon Ong & Christian Walder. Canberra February June 2018

Cheng Soon Ong & Christian Walder. Canberra February June 2018 Cheng Soon Ong & Christian Walder Research Group and College of Engineering and Computer Science Canberra February June 2018 (Many figures from C. M. Bishop, "Pattern Recognition and ") 1of 89 Part II

More information

Math Lecture 18 Notes

Math Lecture 18 Notes Math 1010 - Lecture 18 Notes Dylan Zwick Fall 2009 In our last lecture we talked about how we can add, subtract, and multiply polynomials, and we figured out that, basically, if you can add, subtract,

More information

Chi-square tests. Unit 6: Simple Linear Regression Lecture 1: Introduction to SLR. Statistics 101. Poverty vs. HS graduate rate

Chi-square tests. Unit 6: Simple Linear Regression Lecture 1: Introduction to SLR. Statistics 101. Poverty vs. HS graduate rate Review and Comments Chi-square tests Unit : Simple Linear Regression Lecture 1: Introduction to SLR Statistics 1 Monika Jingchen Hu June, 20 Chi-square test of GOF k χ 2 (O E) 2 = E i=1 where k = total

More information

Gradient Descent Methods

Gradient Descent Methods Lab 18 Gradient Descent Methods Lab Objective: Many optimization methods fall under the umbrella of descent algorithms. The idea is to choose an initial guess, identify a direction from this point along

More information

Math 2142 Homework 5 Part 1 Solutions

Math 2142 Homework 5 Part 1 Solutions Math 2142 Homework 5 Part 1 Solutions Problem 1. For the following homogeneous second order differential equations, give the general solution and the particular solution satisfying the given initial conditions.

More information

26, 24, 26, 28, 23, 23, 25, 24, 26, 25

26, 24, 26, 28, 23, 23, 25, 24, 26, 25 The ormal Distribution Introduction Chapter 5 in the text constitutes the theoretical heart of the subject of error analysis. We start by envisioning a series of experimental measurements of a quantity.

More information

Simple Linear Regression for the MPG Data

Simple Linear Regression for the MPG Data Simple Linear Regression for the MPG Data 2000 2500 3000 3500 15 20 25 30 35 40 45 Wgt MPG What do we do with the data? y i = MPG of i th car x i = Weight of i th car i =1,...,n n = Sample Size Exploratory

More information

Bivariate distributions

Bivariate distributions Bivariate distributions 3 th October 017 lecture based on Hogg Tanis Zimmerman: Probability and Statistical Inference (9th ed.) Bivariate Distributions of the Discrete Type The Correlation Coefficient

More information

Introduction to Error Analysis

Introduction to Error Analysis Introduction to Error Analysis Part 1: the Basics Andrei Gritsan based on lectures by Petar Maksimović February 1, 2010 Overview Definitions Reporting results and rounding Accuracy vs precision systematic

More information

EC212: Introduction to Econometrics Review Materials (Wooldridge, Appendix)

EC212: Introduction to Econometrics Review Materials (Wooldridge, Appendix) 1 EC212: Introduction to Econometrics Review Materials (Wooldridge, Appendix) Taisuke Otsu London School of Economics Summer 2018 A.1. Summation operator (Wooldridge, App. A.1) 2 3 Summation operator For

More information

Conjugate-Gradient. Learn about the Conjugate-Gradient Algorithm and its Uses. Descent Algorithms and the Conjugate-Gradient Method. Qx = b.

Conjugate-Gradient. Learn about the Conjugate-Gradient Algorithm and its Uses. Descent Algorithms and the Conjugate-Gradient Method. Qx = b. Lab 1 Conjugate-Gradient Lab Objective: Learn about the Conjugate-Gradient Algorithm and its Uses Descent Algorithms and the Conjugate-Gradient Method There are many possibilities for solving a linear

More information

Lecture 48 Sections Mon, Nov 16, 2009

Lecture 48 Sections Mon, Nov 16, 2009 and and Lecture 48 Sections 13.4-13.5 Hampden-Sydney College Mon, Nov 16, 2009 Outline and 1 2 3 4 5 6 Outline and 1 2 3 4 5 6 and Exercise 13.4, page 821. The following data represent trends in cigarette

More information

STATISTICS OF OBSERVATIONS & SAMPLING THEORY. Parent Distributions

STATISTICS OF OBSERVATIONS & SAMPLING THEORY. Parent Distributions ASTR 511/O Connell Lec 6 1 STATISTICS OF OBSERVATIONS & SAMPLING THEORY References: Bevington Data Reduction & Error Analysis for the Physical Sciences LLM: Appendix B Warning: the introductory literature

More information

Lecture 2: Linear Models. Bruce Walsh lecture notes Seattle SISG -Mixed Model Course version 23 June 2011

Lecture 2: Linear Models. Bruce Walsh lecture notes Seattle SISG -Mixed Model Course version 23 June 2011 Lecture 2: Linear Models Bruce Walsh lecture notes Seattle SISG -Mixed Model Course version 23 June 2011 1 Quick Review of the Major Points The general linear model can be written as y = X! + e y = vector

More information

Introduction to Python

Introduction to Python Introduction to Python Luis Pedro Coelho Institute for Molecular Medicine (Lisbon) Lisbon Machine Learning School II Luis Pedro Coelho (IMM) Introduction to Python Lisbon Machine Learning School II (1

More information

4 Gaussian Mixture Models

4 Gaussian Mixture Models 4 Gaussian Mixture Models Once you have a collection of feature vectors you will need to describe their distribution. You will do this using a Gaussian Mixture Model. The GMM comprises a collection of

More information

Chapter 5 continued. Chapter 5 sections

Chapter 5 continued. Chapter 5 sections Chapter 5 sections Discrete univariate distributions: 5.2 Bernoulli and Binomial distributions Just skim 5.3 Hypergeometric distributions 5.4 Poisson distributions Just skim 5.5 Negative Binomial distributions

More information

Outline Python, Numpy, and Matplotlib Making Models with Polynomials Making Models with Monte Carlo Error, Accuracy and Convergence Floating Point Mod

Outline Python, Numpy, and Matplotlib Making Models with Polynomials Making Models with Monte Carlo Error, Accuracy and Convergence Floating Point Mod Outline Python, Numpy, and Matplotlib Making Models with Polynomials Making Models with Monte Carlo Error, Accuracy and Convergence Floating Point Modeling the World with Arrays The World in a Vector What

More information

Poisson distribution and χ 2 (Chap 11-12)

Poisson distribution and χ 2 (Chap 11-12) Poisson distribution and χ 2 (Chap 11-12) Announcements: Last lecture today! Labs will continue. Homework assignment will be posted tomorrow or Thursday (I will send email) and is due Thursday, February

More information

Study Sheet. December 10, The course PDF has been updated (6/11). Read the new one.

Study Sheet. December 10, The course PDF has been updated (6/11). Read the new one. Study Sheet December 10, 2017 The course PDF has been updated (6/11). Read the new one. 1 Definitions to know The mode:= the class or center of the class with the highest frequency. The median : Q 2 is

More information

Least Squares. Ken Kreutz-Delgado (Nuno Vasconcelos) ECE 175A Winter UCSD

Least Squares. Ken Kreutz-Delgado (Nuno Vasconcelos) ECE 175A Winter UCSD Least Squares Ken Kreutz-Delgado (Nuno Vasconcelos) ECE 75A Winter 0 - UCSD (Unweighted) Least Squares Assume linearity in the unnown, deterministic model parameters Scalar, additive noise model: y f (

More information

ECE 5615/4615 Computer Project

ECE 5615/4615 Computer Project Set #1p Due Friday March 17, 017 ECE 5615/4615 Computer Project The details of this first computer project are described below. This being a form of take-home exam means that each person is to do his/her

More information

Review of Statistics

Review of Statistics Review of Statistics Topics Descriptive Statistics Mean, Variance Probability Union event, joint event Random Variables Discrete and Continuous Distributions, Moments Two Random Variables Covariance and

More information

Simple Linear Regression Analysis

Simple Linear Regression Analysis LINEAR REGRESSION ANALYSIS MODULE II Lecture - 6 Simple Linear Regression Analysis Dr. Shalabh Department of Mathematics and Statistics Indian Institute of Technology Kanpur Prediction of values of study

More information

Uncertainty and Graphical Analysis

Uncertainty and Graphical Analysis Uncertainty and Graphical Analysis Introduction Two measures of the quality of an experimental result are its accuracy and its precision. An accurate result is consistent with some ideal, true value, perhaps

More information

Error Analysis in Experimental Physical Science Mini-Version

Error Analysis in Experimental Physical Science Mini-Version Error Analysis in Experimental Physical Science Mini-Version by David Harrison and Jason Harlow Last updated July 13, 2012 by Jason Harlow. Original version written by David M. Harrison, Department of

More information

Mathematics 136 Calculus 2 Everything You Need Or Want To Know About Partial Fractions (and maybe more!) October 19 and 21, 2016

Mathematics 136 Calculus 2 Everything You Need Or Want To Know About Partial Fractions (and maybe more!) October 19 and 21, 2016 Mathematics 36 Calculus 2 Everything You Need Or Want To Know About Partial Fractions (and maybe more!) October 9 and 2, 206 Every rational function (quotient of polynomials) can be written as a polynomial

More information

Lecture 10: Linear Multistep Methods (LMMs)

Lecture 10: Linear Multistep Methods (LMMs) Lecture 10: Linear Multistep Methods (LMMs) 2nd-order Adams-Bashforth Method The approximation for the 2nd-order Adams-Bashforth method is given by equation (10.10) in the lecture note for week 10, as

More information

MA/ST 810 Mathematical-Statistical Modeling and Analysis of Complex Systems

MA/ST 810 Mathematical-Statistical Modeling and Analysis of Complex Systems MA/ST 810 Mathematical-Statistical Modeling and Analysis of Complex Systems Review of Basic Probability The fundamentals, random variables, probability distributions Probability mass/density functions

More information

Biostatistics and Design of Experiments Prof. Mukesh Doble Department of Biotechnology Indian Institute of Technology, Madras

Biostatistics and Design of Experiments Prof. Mukesh Doble Department of Biotechnology Indian Institute of Technology, Madras Biostatistics and Design of Experiments Prof. Mukesh Doble Department of Biotechnology Indian Institute of Technology, Madras Lecture - 39 Regression Analysis Hello and welcome to the course on Biostatistics

More information

Jim Lambers MAT 419/519 Summer Session Lecture 13 Notes

Jim Lambers MAT 419/519 Summer Session Lecture 13 Notes Jim Lambers MAT 419/519 Summer Session 2011-12 Lecture 13 Notes These notes correspond to Section 4.1 in the text. Least Squares Fit One of the most fundamental problems in science and engineering is data

More information

p(z)

p(z) Chapter Statistics. Introduction This lecture is a quick review of basic statistical concepts; probabilities, mean, variance, covariance, correlation, linear regression, probability density functions and

More information

Lecture 10: The Normal Distribution. So far all the random variables have been discrete.

Lecture 10: The Normal Distribution. So far all the random variables have been discrete. Lecture 10: The Normal Distribution 1. Continuous Random Variables So far all the random variables have been discrete. We need a different type of model (called a probability density function) for continuous

More information

Political Science 6000: Beginnings and Mini Math Boot Camp

Political Science 6000: Beginnings and Mini Math Boot Camp Political Science 6000: Beginnings and Mini Math Boot Camp January 20, 2010 First things first Syllabus This is the most important course you will take. 1. You need to understand these concepts in order

More information

Complex Numbers. Visualize complex functions to estimate their zeros and poles.

Complex Numbers. Visualize complex functions to estimate their zeros and poles. Lab 1 Complex Numbers Lab Objective: Visualize complex functions to estimate their zeros and poles. Polar Representation of Complex Numbers Any complex number z = x + iy can be written in polar coordinates

More information

Numerical Methods for Initial Value Problems; Harmonic Oscillators

Numerical Methods for Initial Value Problems; Harmonic Oscillators 1 Numerical Methods for Initial Value Problems; Harmonic Oscillators Lab Objective: Implement several basic numerical methods for initial value problems (IVPs), and use them to study harmonic oscillators.

More information

Linear Regression Spring 2014

Linear Regression Spring 2014 Linear Regression 18.05 Spring 2014 Agenda Fitting curves to bivariate data Measuring the goodness of fit The fit vs. complexity tradeoff Regression to the mean Multiple linear regression January 1, 2017

More information

2.5 The Fundamental Theorem of Algebra.

2.5 The Fundamental Theorem of Algebra. 2.5. THE FUNDAMENTAL THEOREM OF ALGEBRA. 79 2.5 The Fundamental Theorem of Algebra. We ve seen formulas for the (complex) roots of quadratic, cubic and quartic polynomials. It is then reasonable to ask:

More information

Regression I - the least squares line

Regression I - the least squares line Regression I - the least squares line The difference between correlation and regression. Correlation describes the relationship between two variables, where neither variable is independent or used to predict.

More information

ECON The Simple Regression Model

ECON The Simple Regression Model ECON 351 - The Simple Regression Model Maggie Jones 1 / 41 The Simple Regression Model Our starting point will be the simple regression model where we look at the relationship between two variables In

More information

Integration of Rational Functions by Partial Fractions

Integration of Rational Functions by Partial Fractions Title Integration of Rational Functions by MATH 1700 MATH 1700 1 / 11 Readings Readings Readings: Section 7.4 MATH 1700 2 / 11 Rational functions A rational function is one of the form where P and Q are

More information

Linear Regression (continued)

Linear Regression (continued) Linear Regression (continued) Professor Ameet Talwalkar Professor Ameet Talwalkar CS260 Machine Learning Algorithms February 6, 2017 1 / 39 Outline 1 Administration 2 Review of last lecture 3 Linear regression

More information

STAT 361 Fall Homework 1: Solution. It is customary to use a special sign Σ as an abbreviation for the sum of real numbers

STAT 361 Fall Homework 1: Solution. It is customary to use a special sign Σ as an abbreviation for the sum of real numbers STAT 361 Fall 2016 Homework 1: Solution It is customary to use a special sign Σ as an abbreviation for the sum of real numbers x 1, x 2,, x n : x i = x 1 + x 2 + + x n. If x 1,..., x n are real numbers,

More information

Data Analysis, Standard Error, and Confidence Limits E80 Spring 2015 Notes

Data Analysis, Standard Error, and Confidence Limits E80 Spring 2015 Notes Data Analysis Standard Error and Confidence Limits E80 Spring 05 otes We Believe in the Truth We frequently assume (believe) when making measurements of something (like the mass of a rocket motor) that

More information

Business Statistics. Lecture 9: Simple Regression

Business Statistics. Lecture 9: Simple Regression Business Statistics Lecture 9: Simple Regression 1 On to Model Building! Up to now, class was about descriptive and inferential statistics Numerical and graphical summaries of data Confidence intervals

More information

CS 195-5: Machine Learning Problem Set 1

CS 195-5: Machine Learning Problem Set 1 CS 95-5: Machine Learning Problem Set Douglas Lanman dlanman@brown.edu 7 September Regression Problem Show that the prediction errors y f(x; ŵ) are necessarily uncorrelated with any linear function of

More information

Topics in Probability and Statistics

Topics in Probability and Statistics Topics in Probability and tatistics A Fundamental Construction uppose {, P } is a sample space (with probability P), and suppose X : R is a random variable. The distribution of X is the probability P X

More information

Introduction to Data Analysis

Introduction to Data Analysis Introduction to Data Analysis Analysis of Experimental Errors How to Report and Use Experimental Errors Statistical Analysis of Data Simple statistics of data Plotting and displaying the data Summary Errors

More information

Numerical Analysis Spring 2001 Professor Diamond

Numerical Analysis Spring 2001 Professor Diamond Numerical Analysis Spring 2001 Professor Diamond Polynomial interpolation: The Polynomial Interpolation Problem: Find a polynomial pÿx a 0 a 1 x... a n x n which satisfies the n 1 conditions pÿx 0 y 0,

More information

Integration of Rational Functions by Partial Fractions

Integration of Rational Functions by Partial Fractions Title Integration of Rational Functions by Partial Fractions MATH 1700 December 6, 2016 MATH 1700 Partial Fractions December 6, 2016 1 / 11 Readings Readings Readings: Section 7.4 MATH 1700 Partial Fractions

More information

Conditioning and Stability

Conditioning and Stability Lab 17 Conditioning and Stability Lab Objective: Explore the condition of problems and the stability of algorithms. The condition number of a function measures how sensitive that function is to changes

More information

Uncertainty in Physical Measurements: Module 5 Data with Two Variables

Uncertainty in Physical Measurements: Module 5 Data with Two Variables : Often data have two variables, such as the magnitude of the force F exerted on an object and the object s acceleration a. In this Module we will examine some ways to determine how one of the variables,

More information

SECTION 7: CURVE FITTING. MAE 4020/5020 Numerical Methods with MATLAB

SECTION 7: CURVE FITTING. MAE 4020/5020 Numerical Methods with MATLAB SECTION 7: CURVE FITTING MAE 4020/5020 Numerical Methods with MATLAB 2 Introduction Curve Fitting 3 Often have data,, that is a function of some independent variable,, but the underlying relationship is

More information

Data Analysis, Standard Error, and Confidence Limits E80 Spring 2012 Notes

Data Analysis, Standard Error, and Confidence Limits E80 Spring 2012 Notes Data Analysis Standard Error and Confidence Limits E80 Spring 0 otes We Believe in the Truth We frequently assume (believe) when making measurements of something (like the mass of a rocket motor) that

More information

TMA4255 Applied Statistics V2016 (5)

TMA4255 Applied Statistics V2016 (5) TMA4255 Applied Statistics V2016 (5) Part 2: Regression Simple linear regression [11.1-11.4] Sum of squares [11.5] Anna Marie Holand To be lectured: January 26, 2016 wiki.math.ntnu.no/tma4255/2016v/start

More information

Calculus I Homework: The Derivatives of Polynomials and Exponential Functions Page 1

Calculus I Homework: The Derivatives of Polynomials and Exponential Functions Page 1 Calculus I Homework: The Derivatives of Polynomials and Exponential Functions Page 1 Questions Example Differentiate the function y = ae v + b v + c v 2. Example Differentiate the function y = A + B x

More information

Linear Least Squares Fitting

Linear Least Squares Fitting Linear Least Squares Fitting Bhas Bapat IISER Pune Nov 2014 Bhas Bapat (IISER Pune) Linear Least Squares Fitting Nov 2014 1 / 16 What is Least Squares Fit? A procedure for finding the best-fitting curve

More information

ECON 4160, Autumn term Lecture 1

ECON 4160, Autumn term Lecture 1 ECON 4160, Autumn term 2017. Lecture 1 a) Maximum Likelihood based inference. b) The bivariate normal model Ragnar Nymoen University of Oslo 24 August 2017 1 / 54 Principles of inference I Ordinary least

More information

Modeling of Data. Massimo Ricotti. University of Maryland. Modeling of Data p. 1/14

Modeling of Data. Massimo Ricotti. University of Maryland. Modeling of Data p. 1/14 Modeling of Data Massimo Ricotti ricotti@astro.umd.edu University of Maryland Modeling of Data p. 1/14 NRiC 15. Model depends on adjustable parameters. Can be used for constrained interpolation. Basic

More information

An introduction to plotting data

An introduction to plotting data An introduction to plotting data Eric D. Black California Institute of Technology v2.0 1 Introduction Plotting data is one of the essential skills every scientist must have. We use it on a near-daily basis

More information

Can you predict the future..?

Can you predict the future..? Can you predict the future..? Gaussian Process Modelling for Forward Prediction Anna Scaife 1 1 Jodrell Bank Centre for Astrophysics University of Manchester @radastrat September 7, 2017 Anna Scaife University

More information

Lecture 16 - Correlation and Regression

Lecture 16 - Correlation and Regression Lecture 16 - Correlation and Regression Statistics 102 Colin Rundel April 1, 2013 Modeling numerical variables Modeling numerical variables So far we have worked with single numerical and categorical variables,

More information

Exercise 4 Modeling transient currents and voltages

Exercise 4 Modeling transient currents and voltages Exercise 4 Modeling transient currents and voltages Basic A circuit elements In a D circuit, the electro-motive forces push the electrons along the circuit and resistors remove that energy by conversion

More information

LECTURE NOTES FYS 4550/FYS EXPERIMENTAL HIGH ENERGY PHYSICS AUTUMN 2013 PART I A. STRANDLIE GJØVIK UNIVERSITY COLLEGE AND UNIVERSITY OF OSLO

LECTURE NOTES FYS 4550/FYS EXPERIMENTAL HIGH ENERGY PHYSICS AUTUMN 2013 PART I A. STRANDLIE GJØVIK UNIVERSITY COLLEGE AND UNIVERSITY OF OSLO LECTURE NOTES FYS 4550/FYS9550 - EXPERIMENTAL HIGH ENERGY PHYSICS AUTUMN 2013 PART I PROBABILITY AND STATISTICS A. STRANDLIE GJØVIK UNIVERSITY COLLEGE AND UNIVERSITY OF OSLO Before embarking on the concept

More information

Chapter 2. Some Basic Probability Concepts. 2.1 Experiments, Outcomes and Random Variables

Chapter 2. Some Basic Probability Concepts. 2.1 Experiments, Outcomes and Random Variables Chapter 2 Some Basic Probability Concepts 2.1 Experiments, Outcomes and Random Variables A random variable is a variable whose value is unknown until it is observed. The value of a random variable results

More information

Introduction to Python

Introduction to Python Introduction to Python Luis Pedro Coelho luis@luispedro.org @luispedrocoelho European Molecular Biology Laboratory Lisbon Machine Learning School 2015 Luis Pedro Coelho (@luispedrocoelho) Introduction

More information

Lecture 1, August 21, 2017

Lecture 1, August 21, 2017 Engineering Mathematics 1 Fall 2017 Lecture 1, August 21, 2017 What is a differential equation? A differential equation is an equation relating a function (known sometimes as the unknown) to some of its

More information

Curve Fitting. Objectives

Curve Fitting. Objectives Curve Fitting Objectives Understanding the difference between regression and interpolation. Knowing how to fit curve of discrete with least-squares regression. Knowing how to compute and understand the

More information

The Treatment of Numerical Experimental Results

The Treatment of Numerical Experimental Results Memorial University of Newfoundl Department of Physics Physical Oceanography The Treatment of Numerical Experimental Results The purpose of these notes is to introduce you to some techniques of error analysis

More information

A( x) B( x) C( x) y( x) 0, A( x) 0

A( x) B( x) C( x) y( x) 0, A( x) 0 3.1 Lexicon Revisited The nonhomogeneous nd Order ODE has the form: d y dy A( x) B( x) C( x) y( x) F( x), A( x) dx dx The homogeneous nd Order ODE has the form: d y dy A( x) B( x) C( x) y( x), A( x) dx

More information

Lorenz Equations. Lab 1. The Lorenz System

Lorenz Equations. Lab 1. The Lorenz System Lab 1 Lorenz Equations Chaos: When the present determines the future, but the approximate present does not approximately determine the future. Edward Lorenz Lab Objective: Investigate the behavior of a

More information

Stat 704 Data Analysis I Probability Review

Stat 704 Data Analysis I Probability Review 1 / 39 Stat 704 Data Analysis I Probability Review Dr. Yen-Yi Ho Department of Statistics, University of South Carolina A.3 Random Variables 2 / 39 def n: A random variable is defined as a function that

More information

STA442/2101: Assignment 5

STA442/2101: Assignment 5 STA442/2101: Assignment 5 Craig Burkett Quiz on: Oct 23 rd, 2015 The questions are practice for the quiz next week, and are not to be handed in. I would like you to bring in all of the code you used to

More information

1111: Linear Algebra I

1111: Linear Algebra I 1111: Linear Algebra I Dr. Vladimir Dotsenko (Vlad) Lecture 6 Dr. Vladimir Dotsenko (Vlad) 1111: Linear Algebra I Lecture 6 1 / 14 Gauss Jordan elimination Last time we discussed bringing matrices to reduced

More information

1.4 Techniques of Integration

1.4 Techniques of Integration .4 Techniques of Integration Recall the following strategy for evaluating definite integrals, which arose from the Fundamental Theorem of Calculus (see Section.3). To calculate b a f(x) dx. Find a function

More information