Before
proceeding with the various concepts in SciPy, it is being expected
that the readers have a basic understanding of Python. SciPy library
depends on the NumPy library, hence learning the basics of NumPy makes
the understanding easy.
Description: *Scipy is a free and open source library used in mathematics, scientific computing, Engineering, and technical computing. *It is collection of mathematical algorithms and convenience functions built on NumPy Data Structures *It is organized into sub-packages covering different scientific computing areas *It is a data processing and prototyping environment rivaling MATLAB *A wide range of computations can be done by using SciPy library *It
contains sub-modules for applications like Integration, Interpolation,
Image Processing, Optimization, Special Functions and Statistics, etc. *USAGE: For solving -Integration, -differentiation, -Interpolation -optimizations -Bessel's functions -Legendre polynomials -Gamma functions -Error functions -solving differential equations -AND A LOT MORE complex mathematical functions
You can use pip to install SciPy via command prompt as-
>>> pip install scipy
In case of PyCharm
PyCharm->settings->project->project interpreter->add(+)->type scipy and install
Then, you can import SciPy as:
>>> import scipy
Numpy VS SciPy
Numpy:
*Numpy is written in C and use for mathematical or numeric calculation. *It is faster than other Python Libraries *Numpy is the most useful library for Data Science to perform basic calculations. *Numpy contains nothing but array data type which performs the most basic operations
*like sorting, shaping ,indexing etc.
SciPy:
*SciPy is built in top of the NumPy *SciPy is a fully-featured version of Linear Algebra while Numpy contains only a few
features
*Most new Data Science features are available in Scipy rather than Numpy.
SciPy sub-modules includes:
Special functions (scipy.special) Integration (scipy.integrate) Optimization (scipy.optimize) Interpolation (scipy.interpolate) Fourier Transforms (scipy.fftpack) Signal Processing (scipy.signal) Linear Algebra (scipy.linalg) Sparse Eigenvalue Problems with ARPACK Compressed Sparse Graph Routines (scipy.sparse.csgraph) Spatial data structures and algorithms (scipy.spatial) Statistics (scipy.stats) Multidimensional image processing (scipy.ndimage) File IO (scipy.io) Weave(scipy.weave) And many more....
Each of the above sub-modules provides different functionalities like Uni-variate interpolation in scipy.interpolate sub-module provides some the useful functionalities like (from scipy.interpolate import *)
interp1d(x, y[, kind, axis, copy, %u2026]) Interpolate a 1-D function. BarycentricInterpolator(xi[, yi, axis]) The interpolating polynomial for a set of points KroghInterpolator(xi, yi[, axis]) Interpolating polynomial for a set of points. PchipInterpolator(x, y[, axis, extrapolate]) PCHIP 1-d monotonic cubic interpolation. barycentric_interpolate(xi, yi, x[, axis]) Convenience function for polynomial interpolation. krogh_interpolate(xi, yi, x[, der, axis]) Convenience function for polynomial interpolation. pchip_interpolate(xi, yi, x[, der, axis]) Convenience function for pchip interpolation. Akima1DInterpolator(x, y[, axis]) Akima interpolator CubicSpline(x, y[, axis, bc_type, extrapolate]) Cubic spline data interpolator. PPoly(c, x[, extrapolate, axis]) Piecewise polynomial in terms of coefficients and breakpoints BPoly(c, x[, extrapolate, axis]) Piecewise polynomial in terms of coefficients and breakpoints.
Data Structure: The
basic data structure used by SciPy is a multidimensional array provided
by the NumPy module. NumPy provides some functions for Linear Algebra,
Fourier Transforms and Random Number Generation, but not with the
generality of the equivalent functions in SciPy.
A sample program: Cubic Root Function:
Cubic Root function finds the cube root of values.
Syntax: scipy.special.cbrt(x)
Example:
from scipy.special import cbrt
#Find cubic root of 27 & 64 using cbrt() function
cb = cbrt([27,64])#print value of cb print(cb)
Comments
Sreeja
5-May-2019 07:48:40 AM