Skip to content

Commit

Permalink
Update linalg.rst
Browse files Browse the repository at this point in the history
Complemented linreg() documentation
  • Loading branch information
prcastro committed May 10, 2014
1 parent 4af04b9 commit 74db0ee
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions doc/stdlib/linalg.rst
Original file line number Diff line number Diff line change
Expand Up @@ -440,9 +440,16 @@ Linear algebra functions in Julia are largely implemented by calling functions f

Concatenate matrices block-diagonally. Currently only implemented for sparse matrices.

.. function:: linreg(x, y)

Determine parameters ``[a, b]`` that minimize the squared error between ``y`` and ``a+b*x``.
.. function:: linreg(x, y) -> [a; b]

Linear Regression. Returns ``a`` and ``b`` such that ``a+b*x`` is the closest line to the given points ``(x,y)``. In other words, this function determines parameters ``[a, b]`` that minimize the squared error between ``y`` and ``a+b*x``.
**Example**::
julia> using PyPlot;
julia> x = float([1:12]);
julia> y = [5.5; 6.3; 7.6; 8.8; 10.9; 11.79; 13.48; 15.02; 17.77; 20.81; 22.0; 22.99];
julia> a, b = linreg(x,y); # Linear regression
julia> plot(x, y, "o"); # Plot (x,y) points
julia> plot(x, [a+b*i for i in x]); # Plot the line determined by the linear regression

.. function:: linreg(x, y, w)

Expand Down

0 comments on commit 74db0ee

Please sign in to comment.