Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

How to estimate the uncertainty of a slope for static calibration or regression

# data of resistance measurements: voltage vs current

import numpy as np
import matplotlib.pyplot as plt

# data
U = np.array([4.5, 6, 7, 8, 9, 10]) # voltage in V
I = np.array([109.5, 115.3, 129.2, 134.8, 142.1, 144.6]) # current in A

plt.plot(U, I, 'o', label='data')
plt.errorbar(U, I, xerr=0.15, yerr=1.5, fmt='none')

plt.plot(np.unique(U), np.poly1d(np.polyfit(U, I, 1))(np.unique(U)), label='fit')
plt.plot([4.5, 10.5], [102,155], 'r--', label='linear fit')
plt.plot([4.5, 10.5], [115,143], 'r--', label='linear fit')
plt.xlabel('U [V]')
plt.ylabel('I [mA]')


<Figure size 640x480 with 1 Axes>

The method:

  1. Draw the best line using polynomial regression, polyfit

  2. Using points and error bars draw the minimum and maximum slopes

  3. Get static sensitivity, i.e. slope uncertainty as the half the difference between the max and min slopes

for instance:

m=147107104.5=7.27 m = \frac{147 - 107}{10 - 4.5} = 7.27 mA/V

m=14511510.54.5=5.45 m = \frac{145 - 115}{10.5 - 4.5} = 5.45 mA/V

m=152106105=9.20 m = \frac{152 - 106}{10 - 5} = 9.20 mA/V

Uncertainty

Δm=(9.205.45)/2=1.875 \Delta m = (9.20 - 5.45)/2 = 1.875 mA/V

Use two standard figures and the correct statement:

The slope is has best estimate of 7.3±1.97.3 \pm 1.9 mA/V