Skip to main content
added 10 characters in body
Source Link
devnull
  • 9.8k
  • 2
  • 18
  • 44

First make sure both units have the same magnitude (V and A, mV and mA etc).

Second, if you force the intercept to zero and switch V with A, so the slope is directly the resistance, the code becomes simply:

import numpy as np

voltage = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
current = np.array([3, 6, 6, 10, 9, 15, 14, 16, 20, 25])
sloperesistance = np.sum(voltage*current)/np.sum(current**2)
print(sloperesistance)

First make sure both units have the same magnitude (V and A, mV and mA etc).

Second, if you force the intercept to zero and switch V with A, so the slope is directly the resistance, the code becomes simply:

import numpy as np

voltage = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
current = np.array([3, 6, 6, 10, 9, 15, 14, 16, 20, 25])
slope = np.sum(voltage*current)/np.sum(current**2)
print(slope)

First make sure both units have the same magnitude (V and A, mV and mA etc).

Second, if you force the intercept to zero and switch V with A, so the slope is directly the resistance, the code becomes simply:

import numpy as np

voltage = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
current = np.array([3, 6, 6, 10, 9, 15, 14, 16, 20, 25])
resistance = np.sum(voltage*current)/np.sum(current**2)
print(resistance)
Source Link
devnull
  • 9.8k
  • 2
  • 18
  • 44

First make sure both units have the same magnitude (V and A, mV and mA etc).

Second, if you force the intercept to zero and switch V with A, so the slope is directly the resistance, the code becomes simply:

import numpy as np

voltage = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
current = np.array([3, 6, 6, 10, 9, 15, 14, 16, 20, 25])
slope = np.sum(voltage*current)/np.sum(current**2)
print(slope)