diff options
author | Alberto Ruiz <aruiz@um.es> | 2014-05-21 10:30:55 +0200 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2014-05-21 10:30:55 +0200 |
commit | 197e88c3b56d28840217010a2871c6ea3a4dd1a4 (patch) | |
tree | 825be9d6c9d87d23f7e5497c0133d11d52c63535 /packages/hmatrix/examples/pinv.hs | |
parent | e07c3dee7235496b71a89233106d93f6cc94ada1 (diff) |
update dependencies, move examples etc
Diffstat (limited to 'packages/hmatrix/examples/pinv.hs')
-rw-r--r-- | packages/hmatrix/examples/pinv.hs | 20 |
1 files changed, 0 insertions, 20 deletions
diff --git a/packages/hmatrix/examples/pinv.hs b/packages/hmatrix/examples/pinv.hs deleted file mode 100644 index 7de50b8..0000000 --- a/packages/hmatrix/examples/pinv.hs +++ /dev/null | |||
@@ -1,20 +0,0 @@ | |||
1 | import Numeric.LinearAlgebra | ||
2 | import Graphics.Plot | ||
3 | import Text.Printf(printf) | ||
4 | |||
5 | expand :: Int -> Vector Double -> Matrix Double | ||
6 | expand n x = fromColumns $ map (x^) [0 .. n] | ||
7 | |||
8 | polynomialModel :: Vector Double -> Vector Double -> Int | ||
9 | -> (Vector Double -> Vector Double) | ||
10 | polynomialModel x y n = f where | ||
11 | f z = expand n z <> ws | ||
12 | ws = expand n x <\> y | ||
13 | |||
14 | main = do | ||
15 | [x,y] <- (toColumns . readMatrix) `fmap` readFile "data.txt" | ||
16 | let pol = polynomialModel x y | ||
17 | let view = [x, y, pol 1 x, pol 2 x, pol 3 x] | ||
18 | putStrLn $ " x y p 1 p 2 p 3" | ||
19 | putStrLn $ format " " (printf "%.2f") $ fromColumns view | ||
20 | mplot view | ||