Search code examples
pythonpython-3.xdataframescatter-plotintercept

How do I calculate y for every value of x if the slope a set to 10 and the intercept b to 0?


I have a small set of data. I used python3 to read it and created a scatter plot. My next task is to set the slope a to 10 and the intercept b to 0 and calculate y for every value of x. The task says I should not use any existing linear regression functions. I have been stuck for some time on this. How can I do that?


Solution

  • If your slope is already set to 10, I don't see why you need to use Linear Regression. I hope I'm not missing anything from your task.

    However, keeping that aside if you need to get a list in python with all elements multiplied by your slope a then you can use a list comprehension to find this new list in the following way:

    y_computed = [item*a for item in x]