
-------------------------------------------- -- 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

wren:
-------------------------------------------- -- Announcing: logfloat 0.8.2 --------------------------------------------
I just released a new package, logfloat, for manipulating log-domain floating numbers.
Arch Linux package now ready, http://aur.archlinux.org/packages.php?ID=18832

wren ng thornton wrote:
-------------------------------------------- -- Announcing: logfloat 0.8.2 -------------------------------------------- [...] 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.
It looks like Hackage's build bot doesn't do `runhaskell Setup.hs haddock` for generating the documentation. So for now at least, the documentation can be found at: http://code.haskell.org/~wren/logfloat/dist/doc/html/logfloat/ I'll work on correcting that in the future. -- Live well, ~wren

I should point out just in case that 1 / 0 isn't infinity on all Fractional types (e.g. Rational). I guess it shouldn't cause a problem with your library, but a warning on the Haddock entry would be nice to avoid surprising people who didn't see the internal implementation. Nice lib, by the way. Thanks, -- Felipe.

Felipe Lessa wrote:
I should point out just in case that 1 / 0 isn't infinity on all Fractional types (e.g. Rational). I guess it shouldn't cause a problem with your library, but a warning on the Haddock entry would be nice to avoid surprising people who didn't see the internal implementation.
Nice lib, by the way. Thanks,
Ah, interesting. I missed that one. I'm wondering if there's any portable notion of infinity on Rationals. GHC.Real uses 1%0, but Hugs gives an overflow for toRational(1/0)... Time to go digging. In the mean time I'll add a note about it. Thanks. -- Live well, ~wren

-------------------------------------------- -- Announcing: logfloat 0.8.5 -------------------------------------------- New official release of the logfloat package for manipulating log-domain floating numbers. This is primarily a maintenance release updating the documentation and with minor tweaks on typeclass-restricted polymorphism. Substantively, I also broke out a new type class for numbers which can represent transfinite values. This is primarily to deal with issues about Rationals and other Fractional types which cannot represent them. I also decided to switch the code over to *.hs format so that the Hackage build bot can generate the documentation more reliably. -------------------------------------------- -- Description -------------------------------------------- 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 Haddock (Darcs version): http://code.haskell.org/~wren/logfloat/dist/doc/html/logfloat/ -- Live well, ~wren
participants (3)
-
Don Stewart
-
Felipe Lessa
-
wren ng thornton