[Numpy-discussion] numpy or scipy ?
Tue Sep 9 01:45:11 CDT 2008
2008/9/8 xiaojf <FDU.email@example.com>:
> Hi all,
> I'm trying to replace matlab with python in my daily work and I have
> several problems now.
> 1) Which one should I use, numpy or scipy ? I found that numpy and
> scipy have many overlap functions and modules, such as numpy.linalg
> and scipy.linaly.
> Maybe I should use numpy in some occasions and use scipy in the other
In addition to what others have said - numpy is basic array
operations, scipy is any sophisticated calculations - I should point
out that there are many functions from numpy that are, for historical
reasons, simply reexported as names in scipy. For example,
In : scipy.sin == numpy.sin
These functions will obviously behave identically. However, some
functions provide extended versions in scipy:
In : numpy.sqrt(-1.)
In : scipy.sqrt(-1.)
The rule here is that scipy has the more "scientifically-correct"
versions, while numpy has the more efficient and less surprising
versions (notice that scipy.sqrt must return a complex array if any
element of its input is real but negative, so its return type depends
on the input value...)
For the most part, though, scipy has tools and algorithms you might
need for numerical calculations - a good rule of thumb is that it has
tools to solve most of the problems described in the "Numerical
Recipes" books - while numpy is a simple array library.
More information about the Numpy-discussion