Python Scipy Introduction

Python Scipy Introduction

           Introduction to SciPy Library

Pre-requisite for SciPy:
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.

*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.
   For solving
    -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 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 is built in top of the NumPy
    *SciPy is a fully-featured version of Linear Algebra while Numpy contains only a few
    *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 (
        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)


 from scipy.special import cbrt
#Find cubic root of 27 & 64 using cbrt() function
 cb = cbrt([27, 64])
#print value of cb

Output: array([3., 4.])

##Article contributed by Yashwanth Gudigamolla

More Articles of yashwanth gudigamolla:

Name Views Likes
Python SciPy stats.skew() function 1591 17
Python Scipy Stats 1169 14
Python SciPy stats beta() function 2030 14
Python Scipy Special (List of Different Functions) 1550 15
Python SciPy Integration 1417 12
Python Scipy Fourier Transforms(scipy.fftpack) 1466 17
Python Scipy linalg 1319 13
Python SciPy stats.expon() function 2288 17
Python SciPy stats.chi() function 994 24
Python Scipy Multidimentional image processing (scipy.ndimage) 1622 26
SciPy - ODR 1488 23
Python SciPy stats.cosine() function 959 14
Python SciPy stats.trim1() function 1051 11
Python SciPy stats.tvar() function 1108 16
Python SciPy stats.tvar() function 1052 23
SciPy - Basic Functionality 1153 27
Python SciPy stats.betaprime() function 1007 13
Python Scipy CSGraph 1206 19
Python Scipy File Input and Output (IO) 1617 20
Python Scipy Optimize 1444 23
Python Scipy Special package (scipy.special) 1108 25
Python SciPy stats.tsem() function 949 12
Python SciPy stats.variation() function 1386 16
Python SciPy stats.tsem() function 998 14
SciPy - Spatial 1181 25
Python program to insert an element into binary search tree 9697 29
Python SciPy stats.chi2() function 1908 18
Python SciPy Interpolation 6665 21
C++ program to find inorder predecessor and successor for a given key in binary search tree with recursion 2483 15
python program to check if two trees are identical using recursion 1193 12
Python SciPy constants 2014 18
Python SciPy stats.sem() function 1340 22
Python Scipy Introduction 1687 26
Python SciPy stats alpha() function 1171 23
SciPy - Cluster 1286 20


  • Sreeja
    5-May-2019 07:48:40 AM
    Cleared my confusion 
    Thank you so much