haskell / statistics

A fast, high quality library for computing with statistics in Haskell.
http://hackage.haskell.org/package/statistics
BSD 2-Clause "Simplified" License
300 stars 68 forks source link

Invalid documentation for `ols`? #200

Open gallais opened 1 year ago

gallais commented 1 year ago

I have been porting part of this library to Idris and so I have been looking at it with more precise types in mind. Which leads me to:

solve :: Matrix m m -> Vector m -> Vector m

qr :: Matrix m n -> (Matrix m n, Matrix n n) (Note the r <- M.replicate n n 0 and a <- M.thaw mat (aka q))

multiplyV :: Matrix m n -> Vector n -> Vector m

And so I don't see how ols is supposed to typecheck:

ols :: Matrix m n -> Vector n -> Vector ?
ols a b = solve r (transpose q {- :: Matrix n m -} `multiplyV` b) -- mismatch b should have type Vector m
  where  (q,r) = qr a -- q :: Matrix m n, r :: Matrix n n

Is the comment for ols wrong? Should it read "/b/ has the same length as columns rows in /A/"?