Reggies Linear Regression Project infinite

in Reggie Linear Regression

Wouldn’t infinite remain the smallest throughout the loops?

datapoints = [(1, 2), (2, 0), (3, 4), (4, 4), (5, 3)]
smallest_error = float(“inf”)
best_m = 0
best_b = 0

for m in possible_ms:
for b in possible_bs:
error = calculate_all_error(m, b, datapoints)
if error < smallest_error:
best_m = m
best_b = b
smallest_error = error

print(best_m, best_b, smallest_error)

I don’t understand why we have smallest_error = float(“inf”)
it seems to me that logically if infinity is smaller than anything else, it would never be replaced by any other “smallest_error”

can someone explain?

Infinity is larger than anything else. The limit as 1/x as x approaches infinity is smaller than anything else.

1 Like

ah yes… LARGER! this makes muuuuch more sense. thank you.