Week 2 Pre-Lab

ucla | PHYSICS 4AL | 2023-01-16T16:28


Table of Contents

Definitions


Big Ideas


Q=(A+B)2=400 sps. x=A+B=20   δx=(δA)2+(δB)2=5 δQ=2δxxQ=200

# assuming the data is given by numpy arrays "x,y"
# assuming matplotlib imported as "plt"

# assigning variables
res, cov = np.polyfit(x,y,1,cov=True)

# fitting data to liner function
plt.plot(x,res[0]*x+res[1],'r',label="fit")

# extracting fit coeff(s)
slope = res[0]
intercept = res[1]

# extracting covariance matrix elements
var_slope = cov[0][0]
var_intercept = cov[1][1]
covar = cov[0][1] # or cov[1][0]

Resources


📌

**SUMMARY
**