ENH: Implement CDF of the von Mises distribution#111
Conversation
|
The inputs and outputs for the CDF are |
|
The math looks sound here. Input and output should be a simple scalar here so we can turn this into a regular ufunc. I do not understand why this was taking arrays as input before. Could you chime in @WarrenWeckesser ? |
I agree; I would expect the C++ implementation of The existing Cython code accepts input arrays with arbitrary dimensions, but it uses NumPy functions and loops to create an ad hoc implementation of broadcasting of |
|
@fbourgey, to help you keep on track, I recommend pairing each xsf PR adding a new function to an associated SciPy PR adding a new ufunc/gufunc (temporarily checking out and pinning the xsf subproject to your xsf PR branch). This is the workflow I use. |
Yeah, when it's ready. Usually what I try to do is work on SciPy and xsf feature branches in parallel and PR them at the same time when they are ready for review. Then we can merge the xsf PR first, make an xsf release, and then change the xsf submodule in the SciPy from your associated xsf feature branch to the new release. |
|
@dschmitz89 I've tried to make this a scalar kernel and added a few tests with some SciPy reference values. |
dschmitz89
left a comment
There was a problem hiding this comment.
I think we can get this into the next xsf release once the merge conflicts are resolved.
My main blocker is adding references: does the current SciPy code or the PR that added this include some useful ones?
| R = 0; | ||
| V = 0; |
There was a problem hiding this comment.
I guess you just followed the code in SciPy but let's use typical C++ style and use lower letters for variables.
@dschmitz89 I've used lower case letters, strengthen test coverage. I've added the same tests as those in scipy/stats/tests/test_distributions.py::TestVonMises. Let me know what you think. |
|
Thanks @fbourgey , tests and implementation look good! I would still like to add a reference to the code comments. |
Sorry, I missed that. I've just added a ref. |
| } | ||
|
|
||
| XSF_HOST_DEVICE inline double von_mises_cdf_normalapprox(double k, double x) { | ||
| double b = xsf::cephes::detail::SQRT2OPI / cephes::i0e(k); // Check for negative k |
There was a problem hiding this comment.
Its not entirely clear what the "check for negative k" comment means?
| #include <xsf/stats.h> | ||
|
|
||
| TEST_CASE("von Mises CDF test", "[von_mises_cdf][xsf_tests]") { | ||
| // Reference values from scipy.stats._stats |
There was a problem hiding this comment.
It might be good to include the permalink since presumably von_mises_cdf will be removed at some point if it is replaced by this
…rresponding test case + remove stale comment
|
@dschmitz89 @j-bowhay do you think this can be merged now? |
Reference issue
Toward #98
What does this implement/fix?
Implement the CDF of the von Mises distribution and related helper functions from
von_mises_cdf