[Numpy-discussion] no ordinary Bessel functions?

Robert Kern robert.kern at gmail.com
Mon Dec 14 23:39:36 EST 2009


On Mon, Dec 14, 2009 at 22:30, Dr. Phillip M. Feldman
<pfeldman at verizon.net> wrote:
>
> When I issue the command
>
> np.lookfor('bessel')
>
> I get the following:
>
> Search results for 'bessel'
> ---------------------------
> numpy.i0
>    Modified Bessel function of the first kind, order 0.
> numpy.kaiser
>    Return the Kaiser window.
> numpy.random.vonmises
>    Draw samples from a von Mises distribution.
>
> I assume that there is an ordinary (unmodified) Bessel function in NumPy,

Nope. i0() is only in numpy to support the kaiser() window. Our policy
on special functions is to include those which are exposed by C99 with
a few exceptions for those that are necessary to support other
functions in numpy. scipy.special is the place to go for general
special function needs.

> but have not been able to figure out how to access it. Also, I need to
> operate sometimes on scalars, and sometimes on arrays. For operations on
> scalars, are the NumPy Bessel functions significantly slower than the SciPy
> Bessel functions?

I recommend using the %timeit magic in IPython to test such things:


In [1]: from scipy import special
%y
In [2]: %timeit numpy.i0(1.0)
1000 loops, best of 3: 921 µs per loop

In [3]: %timeit special.i0(1.0)
100000 loops, best of 3: 5.6 µs per loop

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
  -- Umberto Eco



More information about the NumPy-Discussion mailing list