Linear Regression

Question: Linear regression attempts to model the relationship between two variables and provides a linear equation for value prediction. The formula for the best-fitting line (or regression line) is y = mx + b, where m is the slope of the line and b is the y-intercept. You can find out how to calculate 'm' and 'b' here. Create a function 'linreg' that calculates the regression line and returns a 2 element list, the first being the y-intercept and the second being the slope of the line.

More Information:

https://en.wikipedia.org/wiki/Linear_regression

Example

                                
                                q)signal:til 100
q)price:3*til 100
q)linreg[signal;price]
0 3f
                                
                            

Solution

Tags:
functions statistics
Searchable Tags
algorithms api architecture asynchronous c csv data structures dictionaries disk feedhandler finance functions ingestion ipc iterators machine learning math multithreading optimizations realtime shared library sql statistics streaming strings tables temporal utility websockets