NumPy and SciPy are two essential libraries in the Python programming ecosystem and while both
are used for math type things there are both fundamental differences and areas of overlap
between them so let's get into what they are how they can be differentiated and then some
use cases, so NumPy. NumPy is an abbreviation it's an abbreviation for numerical python,
NumPy-- numerical Python --it lets you do stuff with numbers now NumPy light works with
large multi-dimensional arrays and matrices along with a large collection of high-level
mathematical functions to operate on these arrays. Multi-dimensional arrays you say, what are those?
Well you can think of multi-dimensional arrays as lists of lists, or even lists of lists of lists.
In essence a one-dimensional array, that's something like this,
it's a it's a simple row of items, like a row of numbers. Then you have a two-dimensional array,
that's like this, and you can think of that as being like a table. Where you have multiple rows,
each of which may contain multiple items. Now this can go even further, we can have
three-dimensional array, this, four-dimensional array you get the idea. Now consider a real life
application, like 3D Graphics modeling, you might have a three-dimensional array representing the X,
the Y, and the Z coordinates of each point in a 3D model, or think about time series data,
where one axis represented chronological order of data. These multi-dimensional arrays are also
called tensors and they're fundamental to a lot of the heavy number crunching required it feels
like physics, mathematics, and machine learning. With NumPy you can perform operations on these
arrays as if they were regular numbers, and NumPy handles all the complexity of
manipulating these data structures, but that's just that's just scratching the surface of what
NumPy is capable of. With the help of NumPy you can perform mathematical operations,
so some basic stuff, like addition, subtraction, or you can do things like squaring on an element.
You can perform statistical operations like calculating the mean, the median, and the standard
deviation of your data. So that's NumPy, numerical python. SciPy, that stands for scientific python,
and it's not as if it's a competing library to NumPy which is just as well given that it
clearly has a better name, SciPy. You see SciPy is actually built on top of NumPy.
SciPy leverages NumPy arrays and extends its capabilities. Now what does this mean in practice
well it means that SciPy can do everything that NumPy can do and more. Some SciPy uses
the array data structure from NumPy and enhances it adding further functionality for more complex
and mathematical and scientific computing tasks. So it's kind of like a NumPy+. So in essence
if you're using SciPy you're also using NumPy, but the focus on SciPy really is on scientific
Computing, and that means support for routines like numerical integration, interpolation,
things like optimization, things like linear algebra, and things related to statistics,
and while some functions can only be performed in SciPy there are overlapping capabilities.
So take for example interpolation, which involves estimating unknown values that fall between known
values, both NumPy and SciPy have support for this, but there are key differences. So let's
illustrate this with a simple example. So suppose we have a set of known data points,
like we've got here, and we want to estimate the values at new points that fall between the known
data, so parts around here. Now with with NumPy we can perform what is called a simple linear
a simple linear interpolation and that uses the NP dot enter P function now this involves
fitting a straight line between each pair of known points so like this and using this to estimate the
unknown values it's quick, it's efficient, and it's often good enough for simple use cases.
SciPy's interpolation capabilities though they go far beyond this. So for example using SciPy we can
support something called cubic interpolation, or specifically cubic spline interpolation.
Now how this works is a little bit different it involves fitting a smooth curve through unknown
data points. So it look more like something like this and this can provide a more accurate
estimate of the unknown values. specially when data has a complex non-linear structure.
NumPy's interpolation is straightforward and it's efficient. SciPy's is more flexible and
sophisticated. So where are the libraries typically used. Well let's say you're working
in data science exploring a large data set to find patterns and insights. With NumPy you can
quickly perform operations like calculating the mean, or standard deviation of your data,
filtering for specific values, or transforming and reshaping your data. NumPy's capabilities
are also well suited to image processing. So let's take a beautifully drawn image like this.
Images can be represented as multi-dimensional arrays, like this,
and here those multimeter dimensional arrays are the dimensions corresponding to say height width
and color channels. And with NumPy you can manipulate these arrays to apply, filters,
Transformations, and other image processing operations. Now on the other hand when you
work requires more advanced and specialized mathematical or scientific functionality,
that's when SciPy comes into play. Take for example the field of signal processing. SciPy
has a suite of functions in its signal module for signal processing. So here's a signal,
and we can for example use its Fast Fourier transform functions, or fft,
and what that can do is is it can convert the signal from the time domain, into the frequency
domain, and that will let you analyze the signals for different frequency components. So that might
look something like a bar chart format like this. If you're designing an aircraft wing and you need
to find the shape that minimizes drag, while satisfying constraints like maximum weight and
material strength, you could use the optimization routines in SciPy to solve this problem.
And look, one key point that underpins the use of both of these libraries is their
efficiency. Both NumPy and SciPy are designed to manage computational resources efficiently,
and that means they handle large data sets and perform complex operations while minimizing the
usage of your computer's memory and processing power. That's one of the reasons why they're
a go-to choice for number crunching tasks. In short if you're working in a field that
involves data analysis or scientific computation chances are you'll be using NumPy, SciPy, or both
if you have any questions please drop us a line below and if you want to see more
videos like this in the future please like And subscribe thanks for watching