# Reggie's Linear Regression - possible_ms & possible_bs variance

This is my first time creating a new project topic, so please forgive any formatting issues.

I just completed the Brute Force Linear Regression project.

My first issue was that I kept running all cells in order which lead to the last list of datapoints being where we tested calculate_all_error.

``````#every point in this dataset lies upon y=x, so the total error should be zero:
datapoints = [(1, 1), (3, 3), (5, 5), (-1, -1)]
print(calculate_all_error(1, 0, datapoints))

#every point in this dataset is 1 unit away from y = x + 1, so the total error should be 4:
datapoints = [(1, 1), (3, 3), (5, 5), (-1, -1)]
print(calculate_all_error(1, 1, datapoints))

#every point in this dataset is 1 unit away from y = x - 1, so the total error should be 4:
datapoints = [(1, 1), (3, 3), (5, 5), (-1, -1)]
print(calculate_all_error(1, -1, datapoints))

#the points in this dataset are 1, 5, 9, and 3 units away from y = -x + 1, respectively, so total error should be
# 1 + 5 + 9 + 3 = 18
datapoints = [(1, 1), (3, 3), (5, 5), (-1, -1)]
print(calculate_all_error(-1, 1, datapoints))
``````

Once I moved ‘datapoints’ down to where I calculated the best ‘m’ & ‘b’ values I found another error.

When I created my ‘possible_bs’ and ‘possible_ms’ I used

``````[i*0.1 for i in range(-100, 101)]
``````

This resulted in some random numbers like ‘-9.700000000000001’ and ‘1.7000000000000002’.

So I decided to round all the numbers to 1 decimal place with

``````[round(i*0.1, 1) for i in range(-100, 101)]
``````

For quite a while I got the ‘best_m = 0.4’, ‘best_b = 1.6’ and ‘smallest_error = 5’

I eventually figured out that my rounding caused the error and when I removed it I got ‘best_m = 0.30000000000000004’, ‘best_b = 1.7000000000000002’ and ‘smallest_error = 4.999999999999999’

So which is the correct/better way to do it? The instructions say to increment by 0.1 which the rounding does a better job of, but when I round I get a different final result.

Hopefully I did this correctly (first time using Github as well), here is my Jupyter Notebook w/ rounding.

Here is my notebook w/out rounding