LATEST

Learn › Research Methods

Graphs and Curve Fitting

Free preview Lesson 28 of 71

🎯 By the end of this lesson you can:
plot and interpret graphs, and fit a straight line by least squares.

Rules for plotting graphs
• Plot the independent variable on the x-axis and the dependent variable on the y-axis.
• Label axes with quantity and unit, for example T2(s2)T^2 \ (s^2).
• Choose scales that use more than half of the graph area; avoid awkward scales such as 3 or 7 units per division.
• Plot points clearly, and add error bars where the uncertainties are significant.
• Draw a best-fit line or curve; do not join points "dot-to-dot" unless the data justify it.
• Give a figure number and a caption. Take the slope with a large triangle using points on the line, not data points.
• Where possible linearise the relationship. For T=2πLgT = 2\pi \sqrt{\frac{L}{g}} plot T2T^2 against LL; the slope is 4π2g\frac{4\pi^{2}}{g}.

Linear least squares
For a straight line y=mx+cy = mx + c fitted to NN points:

m=N∑xy−∑x∑yDm = \frac{N\sum xy - \sum x \sum y}{D}

,

c=∑y−m∑xNc= \frac{\sum y - m\sum x}{N}

,

where D=N∑x2−(∑x)2D = N\sum x^2 - (\sum x)^2.


Worked Example

Fit a straight line to (1, 2.1), (2, 3.9), (3, 6.2), (4, 7.8), (5, 10.1).

Solution

∑x=15\sum x = 15,

∑y=30.1\sum y = 30.1,

∑xy=110.2\sum xy = 110.2,

∑x2=55\sum x^2 = 55,

N=5N = 5.

D=5(55)−152=50D = 5(55) - 15^{2} = 50

.

m=5×110.2−15×30.150=551−451.550=1.99m = \frac{5\times 110.2 - 15\times 30.1}{50} = \frac{551 - 451.5}{50} = 1.99

.

c=30.1−1.99×155=0.05c = \frac{30.1 - 1.99\times15}{5} = 0.05

.

Best-fit line: y=1.99x+0.05y = 1.99x + 0.05.


Spreadsheets (Excel, LibreOffice Calc), Origin, Python (NumPy, SciPy, Matplotlib) and similar tools perform fits and report the uncertainty in slope and intercept; understand what the software is doing and do not accept the output uncritically. The goodness of fit is judged by the residuals and by the reduced chi-squared, χ2=∑[(yi−f(xi))σi]2\chi^{2} = \sum \left[\frac{(y_i -f(x_i))}{\sigma_i}\right]^2 divided by the degrees of freedom; a value near 1 indicates a fit consistent with the stated uncertainties.

You are viewing a free preview. Enrol to unlock the rest of the course and track your progress.