summaryrefslogtreecommitdiff
path: root/examples/kalman.hs
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2008-01-17 18:15:33 +0000
committerAlberto Ruiz <aruiz@um.es>2008-01-17 18:15:33 +0000
commit0d26c1fc0eccdeb585a74d96cbe7861cf20c7bd2 (patch)
tree1747de32361cf1485108aae2dcb82ce4a6d75ebf /examples/kalman.hs
parentc520939e33cc895febed271d5c3218457317bba9 (diff)
f2c.h hack, trying to support both 32 and 64 bit mahines
Diffstat (limited to 'examples/kalman.hs')
-rw-r--r--examples/kalman.hs6
1 files changed, 2 insertions, 4 deletions
diff --git a/examples/kalman.hs b/examples/kalman.hs
index e191cbb..7fbe3d2 100644
--- a/examples/kalman.hs
+++ b/examples/kalman.hs
@@ -26,12 +26,12 @@ type Measurement = Vector Double
26kalman :: System -> State -> Measurement -> State 26kalman :: System -> State -> Measurement -> State
27kalman (System f h q r) (State x p) z = State x' p' where 27kalman (System f h q r) (State x p) z = State x' p' where
28 px = f <> x -- prediction 28 px = f <> x -- prediction
29 pq = f <> p <> trans f -- its covariance 29 pq = f <> p <> trans f + q -- its covariance
30 y = z - h <> px -- residue 30 y = z - h <> px -- residue
31 cy = h <> pq <> trans h + r -- its covariance 31 cy = h <> pq <> trans h + r -- its covariance
32 k = pq <> trans h <> inv cy -- kalman gain 32 k = pq <> trans h <> inv cy -- kalman gain
33 x' = px + k <> y -- new state 33 x' = px + k <> y -- new state
34 p' = (ident (dim x) - k <> h) <> pq -- its covariance 34 p' = (ident (dim x) - k <> h) <> pq -- its covariance
35 35
36sys = System f h q r 36sys = System f h q r
37 37
@@ -49,5 +49,3 @@ main = do
49 print $ fromRows $ take 10 (map sX xs) 49 print $ fromRows $ take 10 (map sX xs)
50 mapM_ (print . sP) $ take 10 xs 50 mapM_ (print . sP) $ take 10 xs
51 mplot (evolution 20 (xs,des)) 51 mplot (evolution 20 (xs,des))
52
53--(<>) = multiply \ No newline at end of file