#1

Hello everyone!

In Reggie’s Linear Regression I get different results depending on the use of the m’s and b’s. It makes a different which of the following list comprehensions I use:

possible_ms = [(i/10) for i in range(-100, 100)]
possible_bs = [i /10 for i in range(-200, 200)]

possible_ms = [i*0.1 for i in range(-100, 100)]
possible_bs = [i*0.1 for i in range(-200, 200)]

The differences are quite small (second, “right” version is m=0.3 and b=1.7, first version is m=0.4 and b=1.6). Anyway, can someone explain why the results are different please??

#2

Hi @gigelig,

Display some or all of the contents of either `possible_ms` or `possible_bs` for the two different methods that you used to compute them, and compare. You’ll notice a small difference between corresponding elements. Then see Floating Point Arithmetic: Issues and Limitations.

#3

Yes you can/should read about floating points & why that happened, BUT I am wondering why the authors don’t correct this as our method finds the same error AND the list comprehension (i /10) creates the desired list (-10 to 10 in .1 increments)
Thoughts CA community? Am I missing something?