summaryrefslogtreecommitdiff
path: root/lib/Numeric/LinearAlgebra/Tests.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Numeric/LinearAlgebra/Tests.hs')
-rw-r--r--lib/Numeric/LinearAlgebra/Tests.hs17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/Numeric/LinearAlgebra/Tests.hs b/lib/Numeric/LinearAlgebra/Tests.hs
index 3f7c847..f8f8bd5 100644
--- a/lib/Numeric/LinearAlgebra/Tests.hs
+++ b/lib/Numeric/LinearAlgebra/Tests.hs
@@ -143,6 +143,22 @@ odeTest = utest "ode" (last (toLists sol) ~~ [-1.7588880332411019, 8.36434890871
143 143
144--------------------------------------------------------------------- 144---------------------------------------------------------------------
145 145
146fittingTest = utest "levmar" ok
147 where
148 xs = map return [0 .. 39]
149 sigma = 0.1
150 ys = map return $ toList $ fromList (map (head . expModel [5,0.1,1]) xs)
151 + scalar sigma * (randomVector 0 Gaussian 40)
152 dat = zipWith3 (,,) xs ys (repeat sigma)
153
154 expModel [a,lambda,b] [t] = [a * exp (-lambda * t) + b]
155 expModelDer [a,lambda,_b] [t] = [[exp (-lambda * t), -t * a * exp(-lambda*t) , 1]]
156
157 sol = fst $ fitModel 1E-4 1E-4 20 (resM expModel, resD expModelDer) dat [1,0,0]
158 ok = and (zipWith f sol [5,0.1,1]) where f (x,d) r = abs (x-r)<2*d
159
160---------------------------------------------------------------------
161
146randomTestGaussian = c :~1~: snd (meanCov dat) where 162randomTestGaussian = c :~1~: snd (meanCov dat) where
147 a = (3><3) [1,2,3, 163 a = (3><3) [1,2,3,
148 2,4,0, 164 2,4,0,
@@ -292,6 +308,7 @@ runTests n = do
292 && rank ((2><3)[1,0,0,1,7*eps,0]) == 2 308 && rank ((2><3)[1,0,0,1,7*eps,0]) == 2
293 , utest "block" $ fromBlocks [[ident 3,0],[0,ident 4]] == (ident 7 :: CM) 309 , utest "block" $ fromBlocks [[ident 3,0],[0,ident 4]] == (ident 7 :: CM)
294 , odeTest 310 , odeTest
311 , fittingTest
295 ] 312 ]
296 return () 313 return ()
297 314