Closed phadej closed 5 years ago
ping @Shimuuar
math-functions
& statistics
are used by criterion
.
https://en.wikipedia.org/wiki/Numerical_Recipes is the original source (this book should be in every technical library)
Btw, I see there is .travis.yml
and appveyor.yml
in the repository, but they are not on.
Is it possible to ping Bryan to enable at least travis for this and statistics
.
I'm working on GHCJS support for https://github.com/haskell-ci/haskell-ci (the successor of https://github.com/hvr/multi-ghc-travis), and the tests do pass locally even with GHCJS. I'd make Travis say that, so you don't need to trust my word on it!
GHCJS support for travis? That would be great!
AFAIR I tried pinging him and then just topok an easy road and just run tests in my fork
Let's see how https://travis-ci.org/phadej/math-functions/builds/578017312 turns out.
I'll try to make it green still today.
EDIT: another attempts:
@phadej I ended up implementing another algorithm from numerical recipes. It provides almost full double preceision (loses 1-2 significant digits at the tails). Still big improvement over single precision (~7 digits). I still need to check
Also is there canonical way to test package with different flag set? Math-functions certainly needs to test bundled implementations of erf, log1p, expm1
@Shimuuar I'd provide both, because additional precision isn't computationally free. And on GHCJS it's slow and criterion
is fine with Float
precision.
https://github.com/ekmett/semigroups/blob/master/cabal.haskell-ci is an example of specifying constraint-set. You need to use configuration file for these.
General policy of this library is that functions by default should provide full precision. Functions which trade precision for speed are OK too but should be clearly marked as such. Here we get into very interesting tradeoffs. On GHC we have access to erfc/erfc from libc which are both precise within 1ulp and probably fastest (I didn't benchmark different implementation of erf yet). It's likely always best choice. On GHCJS using faster erfFast
may be justified.
Thanh there's performance impact. AFAIR criterion spends most of the time on running bootstrap. And I think it doesn't use erf
. If I'm right erf is out of hot code path and performance impact of slower implementation would be negligible
Anyway it's not possible to say anything about usefulness of faster variant of erf without benchmarks
True. Any version would be good probably good enough for criterion
use, it needs some erfc
.
And then we can benchmark, so I'm happy with any result, as far as there is working erfc
.
(Note: in this pr I added the table for erf
results in the tests, and faster one passes those, with 1e-7
error. I used values from https://en.wikipedia.org/wiki/Error_function#Table_of_values to make that table. Maybe there are more precise tabulated values somewhere as well, so if you end up using more precise algorithm, the table and error could (should?) be updated)
I think I'll just upload new version with ghcjs support in the evening and we can sort out performance questions with GHCJS later
As for tables. I just generated tables to 30 significant digits using mpmath
TIL about mpmath
, :+1:
@Shimuuar i'd like to test the version you'd upload, to avoid "testing in production".
It's current master of math-functions. Ready for release but not tagged yet
@Shimuuar thanks. I'll test it in next ~8 hours.
I'll upload it once you say it's OK
I tested master
with my “no monad-par” PR for statistics
and run a criterion benchmark built with GHCJS just fine. As far as I can say, master
looks great.
math-functions-0.3.2.0
is on hackage. Now to statistics
Test suite passes locally when build with GHCJS