
-------------------------------------------- -- Announcing: logfloat 0.8.2 -------------------------------------------- I just released a new package, logfloat, for manipulating log-domain floating numbers. The main reason for casting numbers into the log-domain is to prevent underflow when multiplying many small probabilities as is done in Hidden Markov Models and other statistical models often used for natural language processing. The log-domain also helps prevent overflow when multiplying many large numbers. In rare cases it can speed up numerical computation (since addition is faster than multiplication, though logarithms are exceptionally slow), but the primary goal is to improve accuracy of results. A secondary goal has been to maximize efficiency since these computations are frequently done within a /O(n^3)/ loop. The Data.Numeric.LogFloat module provides a new data type LogFloat which handles all the conversions and optimizations and can be treated as any other number thanks to type classes. -------------------------------------------- -- Links -------------------------------------------- Homepage: http://code.haskell.org/~wren/ Hackage: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/logfloat Darcs: http://code.haskell.org/~wren/logfloat -------------------------------------------- -- Details -------------------------------------------- The package's version numbers start from 0.8 since this began as a port of my Perl module for doing the same thing. The code is very heavily documented, largely for pedagogical reasons. Since Haddock doesn't play very nicely with literate Haskell, there's also a small lhs2hs converter script which gets run when you call: runhaskell Setup.hs haddock. This converter requires the bytestring package. The library proper does not, so I didn't include this dependency for the package itself. The package uses GHC's rewrite rules to do log/exp fusion. In general, since a newtype is used, the module shouldn't add overhead (beyond crossing the log/exp boundary). In the future I'll be experimenting with strictness as well to try to ensure that everything stays in registers for those /O(n^3)/ loops. I'm not sure whether it'd be helpful to keep a lazy version around as well... The LogFloat type is restricted to non-negative numbers. In the future I'll also add a signed variant for those who aren't just doing statistical work. -- Live well, ~wren