summaryrefslogtreecommitdiff
path: root/examples/pinv.hs
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2014-05-08 08:48:12 +0200
committerAlberto Ruiz <aruiz@um.es>2014-05-08 08:48:12 +0200
commit1925c123d7d8184a1d2ddc0a413e0fd2776e1083 (patch)
treefad79f909d9c3be53d68e6ebd67202650536d387 /examples/pinv.hs
parenteb3f702d065a4a967bb754977233e6eec408fd1f (diff)
empty hmatrix-base
Diffstat (limited to 'examples/pinv.hs')
-rw-r--r--examples/pinv.hs20
1 files changed, 0 insertions, 20 deletions
diff --git a/examples/pinv.hs b/examples/pinv.hs
deleted file mode 100644
index 7de50b8..0000000
--- a/examples/pinv.hs
+++ /dev/null
@@ -1,20 +0,0 @@
1import Numeric.LinearAlgebra
2import Graphics.Plot
3import Text.Printf(printf)
4
5expand :: Int -> Vector Double -> Matrix Double
6expand n x = fromColumns $ map (x^) [0 .. n]
7
8polynomialModel :: Vector Double -> Vector Double -> Int
9 -> (Vector Double -> Vector Double)
10polynomialModel x y n = f where
11 f z = expand n z <> ws
12 ws = expand n x <\> y
13
14main = 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