I have two sets of data and I am wondering how to find a polyfit (so that I can get a linear line of best fit) when there are constant errors present in both x and y variables.
Import numpy as np
Import matplotlib as plt                 
data=np.loadtxt('Data/Resistors.csv',skiprows=2,delimiter=',')
print(data)
[[ 0.162032  2.      ]
 [ 0.254001  3.      ]
 [ 0.249856  4.      ]
 [ 0.420033  5.      ]
[ 0.364007  6.      ]]
#Define
I=data[0:,0]
diff_V=data[:,1]
#Error of each variable
err_I=0.03 #Constant error
err_diff_V=0.5 #Constant error
#Polyfitting
fit_diff_V,cov_diff_V=np.polyfit(I,diff_V,1,w=1/(#what should I enter here?),cov=True)
What should I enter in the weight argument so that my line of best fit can take into account the errors contributed by both I and diff_V ?
(my lecturer demonstrated the weighting thing with just one error which is for the independent variable)
