[Haskell-cafe] Matrices

Don Stewart dons at galois.com
Sun Apr 19 09:56:47 EDT 2009


Very cool!

We need an hmatrix-static tutorial!

aruiz:
> Using hmatrix-static:
>
> import Numeric.LinearAlgebra.Static
>
> m = [$mat| 46.0,37.0;
>            71.0,83.0 |]
>
> es = [$mat| 40.9746835443038,42.0253164556962;
>             76.0253164556962,77.9746835443038 |]
>
> chisquare = sum . toList . flatten $ (m - es)^2 / es ::Double
> -- >  1.8732940252518542
>
> Cetin Sert wrote:
>> http://ccnmtl.columbia.edu/projects/qmss/the_chisquare_test/about_the_chisquare_test.html
>>
>> given two matrices,
>>
>> Prelude Data.Matrix.Dense Data.Vector.Dense> m
>> listMatrix (2,2) [46.0,37.0,71.0,83.0]
>> Prelude Data.Matrix.Dense Data.Vector.Dense> es
>> listMatrix (2,2)
>> [40.9746835443038,42.0253164556962,76.0253164556962,77.9746835443038]
>>
>> how can I flatten them to do:
>> [ (o-e)^2 / e | o <- m, e <- es ]
>>
>> or use a function that will apply a given function to every
>> corresponding elements of 2 or n matrices and create a result matrix?
>>
>> If I should use a different matrix type or library altogether, please
>> specify which one and how ^__^"
>>
>> Best Regards,
>> Cetin Sert
>> _______________________________________________
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe


More information about the Haskell-Cafe mailing list