Last active
August 29, 2015 14:23
-
-
Save gavinwhyte/d85b0ed8eb9a9f804cfd to your computer and use it in GitHub Desktop.
Linear Regression
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Statistics.LinearRegression | |
import qualified Data.Vector.Unboxed as U | |
-- Computing a linear regression | |
main = do | |
let xs = U.fromList [1.0, 2.0, 3.0, 4.0, 5.0] :: U.Vector Double | |
let ys = U.fromList [1.0, 2.0, 1.3, 3.75, 2.25] :: U.Vector Double | |
let (b, m) = linearRegression xs ys | |
print $ concat ["y = ", show m, " x + ", show b] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment