Courses / Physics I
Principles of Laboratory Practice

Graphical Analysis and Curve Fitting

Physics I 316 words Free to read

Graphical analysis is the primary tool for extracting physical relationships from data.

Plotting conventions

Linearisation — Many physical laws become linear with the right transformation:

LawPlotSlope
y=ax+by = ax + byy vs xxaa
y=ax2y = ax^{2}yy vs x2x^{2}aa
y=aebxy = ae^{bx}lny\ln y vs xxbb
y=axny = ax^nlogy\log y vs logx\log xnn

Least-squares fit — For y=mx+cy = mx + c, minimise:

χ2=i=1N(yimxic)2σi2\chi^2 = \sum_{i=1}^N \frac{(y_i - mx_i - c)^2}{\sigma_i^2}

Reduced chi-squaredχν2=χ2/(Np)\chi^{2}_\nu = \chi^{2}/(N-p) where pp is the number of fit parameters. A good fit gives χν21\chi^{2}_\nu \approx 1.

import numpy as np
x = np.array([1, 2, 3, 4, 5])
y = np.array([2.1, 3.9, 6.2, 7.8, 10.1])
m, c = np.polyfit(x, y, 1)
print(f"Slope = {m:.2f}, Intercept = {c:.2f}")

Key insight: If your data doesn't linearise as expected, the assumed model may be wrong. The graph tells you this before any statistical test does.
Common pitfall: Fitting a curve to data proves little by itself — enough parameters fit anything. Linearize so theory predicts a straight line, then let the residuals judge: structure in the residuals means the model, not the data, is wrong.
Placeholder: Graphical Analysis and Curve Fitting

Least-Squares Regression

A best-fit line y=mx+by = mx + b minimises the sum of squared residuals:

S=i=1n(yimxib)2S = \sum_{i=1}^{n} (y_i - mx_i - b)^2

Setting S/m=0\partial S/\partial m = 0 and S/b=0\partial S/\partial b = 0 yields slope and intercept.

The correlation coefficient r2r^{2} quantifies fit quality (1 = perfect, 0 = none).

A poor fit may indicate systematic errors or an incorrect theoretical model.
Linear Regression and Data Fitting

Practise this lesson

The explanation above is free to read. The graded practice for this lesson lives in the Tryals app.

14practice questions
2interactive scenes
Start Physics I free

Principles of Laboratory Practice