Birch icon indicating copy to clipboard operation
Birch copied to clipboard

Replace quantile functions

Open lawmurray opened this issue 3 years ago • 1 comments

We recently replaced cdf functions from Boost Math with our own implementations. The aim is to do so for quantile functions too. This will allow us to integrate them with the Expression hierarchy and the various features that it provides, such as automatic differentiation, as well as future accelerator support.

As part of upgrading to C++17, we also replaced the use of the Boost FileSystem library with its new STL equivalent. Quantile functions are the last remaining use of Boost, and will allow us to eliminate it as a dependency. That may have the added side effect of improving build times given the complexity of some Boost code. Generally, though, eliminating dependencies simplifies maintenance, too.

There are two steps:

  1. Augment the test suite with a new set of tests for the quantile functions. See the cdf tests as a starting point. A simple test paradigm would be to repeatedly draw random samples x from the distribution, evaluate y = quantile(cdf(x)), and check that abs(x - y) < ε.
  2. Once the tests are implemented such that all the current Boost-based quantile functions are passing, reimplement them in pure Birch. The quantile functions are found in quantile.birch. Currently most of them use nested C++ code to call Boost functions. The aim is to replace this with pure Birch implementations, as has been done in cdf.birch.

Implementing the quantile functions may involve implementing some special functions, which may have standard approximations based on Taylor expansions or similar. This is part of the fun and a good learning experience. The existing implementations in Boost Math, or in a numerical library such as NumPy, may provide a good reference.

lawmurray avatar Feb 15 '21 05:02 lawmurray

I am willing to work on this issue. Can you please assign this issue to me?

RigvedRocks avatar Dec 11 '23 04:12 RigvedRocks