Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Bessel functions #7

Closed
BaxterEaves opened this issue Oct 4, 2018 · 4 comments
Closed

Add Bessel functions #7

BaxterEaves opened this issue Oct 4, 2018 · 4 comments

Comments

@BaxterEaves
Copy link
Contributor

Hi,

I've implemented modified Bessel functions I0 and I1 for the rv crate, but I think that they would be more useful here. Are you open to a PR for a Bessel trait? With what I have right now it would look something like this:

trait Bessel where Self: Sized {
    /// Modified Bessel function of order 0
    fn i0(self) -> Self;
    /// Modified Bessel function of order 1
    fn i1(self) -> Self;
}

I'm open to adding more Bessel things if you feel this isn't complete enough for a new trait.

@IvanUkhov
Copy link
Member

Thanks! It’s certainly of interest.

What method is used for computing them? Can you please motivate why these particular orders are important? Are there any difficulties with computing Bessel functions of arbitrary orders?

@BaxterEaves
Copy link
Contributor Author

The I0 and I1 modified bessel functions are important for computing the VonMises distribution PDF and variance. In general, bessel functions show up in physics a lot.

There is no problem computing the modified bessel functions for arbitrary order (though the code is a bit of a beast), but the i0 and i1 functions i have are faster for their orders than the general algorithm.

As for the method, I ported the Cephes code packaged with Scipy.

@IvanUkhov
Copy link
Member

All right, given the way they will be most likely invoked, do you think it makes sense to include bessel in their names?

use special::Bessel;
let y = x.bessel_i0();

@BaxterEaves
Copy link
Contributor Author

That makes sense to me. It's more explicit. I'll get on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants