Numpy Statistical Operations
NumPy offers a wide range of statistical functions that allow various statistical calculations on
arrays. These functions can calculate metrics such as mean, median, variance, standard deviation,
minimum, maximum, and more.
min() The [Link]() function is used to find the smallest element in a given NumPy array. It
can compute the minimum value of the entire array, or restrict the search along a specific axis
(row or column), depending on the parameters provided.
import numpy as np
a = [Link]([12,13,45,15,23,45,78,99])
print([Link](a))
amin() The [Link]() function (an alias for the .min() method) is a statistical function in the
NumPy library that returns the minimum element of an array or the minimum elements along a
specified axis.
import numpy as np
a = [Link]([12,13,45,15,23,45,78,99])
print([Link](a))
max() The [Link]() function is used to find the maximum value within a single NumPy
array. It can return the overall maximum value of the flattened array, or the maximum values
along a specified axis (e.g., per row or per column).
import numpy as np
a = [Link]([12,13,45,15,23,45,78,99])
print([Link](a))
amax() The [Link]() function is used to return the maximum element of a NumPy array, or
the maximum elements along a specified axis. It is an alias for [Link]()
import numpy as np
a = [Link]([12,13,45,15,23,45,78,99])
print([Link](a))
mean()The [Link]() function calculates the arithmetic average of elements in a NumPy
array. It sums all the elements and divides by the total number of elements, providing a measure
of central tendency in data analysis.
import numpy as np
a = [Link]([12,13,45,15,23,45,78,99])
print([Link](a))
mode() The MODE function identifies the most frequently occurring, or repetitive, value in a
dataset. It is a statistical measure of central tendency often used to find patterns or common
trends, such as the most popular item sold. If no values repeat, it returns #N/A, and it ignores
text, empty cells, and logical values
import numpy as np
a = [Link]([12,13,45,15,23,45,78,99])
print([Link](a))
median() The [Link]() function is a statistical function in the NumPy library that
calculates the median (middle value) of elements in a given array along a specified axis. The
median is a measure of central tendency that is less sensitive to outliers than the mean.
import numpy as np
a = [Link]([12,13,45,15,23,45,78,99])
print([Link](a))
Sum() The [Link]() function is an aggregate function that returns the sum of array
elements along a specified axis, or the sum of all elements in the entire array if no axis is
specified. It is a core function in NumPy for efficient numerical computation and data analysis.
import numpy as np
a = [Link]([12,13,45,15,23,45,78,99])
print([Link](a))
Prod() The [Link]() function calculates the product of all the elements in a given array
along a specified axis. It is the multiplication equivalent of [Link]()
import numpy as np
a = [Link]([12,13,45,15,23,45,78,99])
print([Link](a))
Ptp() The [Link]() function computes the range (peak-to-peak) of an array, which is the
difference between the maximum and minimum values of the elements. The name "ptp" is an
acronym for "peak to peak".
import numpy as np
a = [Link]([12,13,45,15,23,45,78,99])
print([Link](a))
Percentile() The [Link]() function computes the percentile of data along a specified
axis, representing the value below which a given percentage of observations falls. It is used for
data distribution analysis, such as finding the median
import numpy as np
a = [Link]([12,13,45,15,23,45,78,99])
print([Link](a))
Std() The [Link]() function calculates the standard deviation of elements within a NumPy
array. The standard deviation is a statistical measure that indicates how spread out the values in a
dataset are from their mean value. A low standard deviation means the values are clustered
closely around the mean, while a high standard deviation means they are spread out over a wider
range.
import numpy as np
a = [Link]([12,13,45,15,23,45,78,99])
print([Link](a))
Var() The [Link]() function computes the variance of elements in a given array, which is a
statistical measure of the spread or dispersion of the data points from their mean value. A higher
variance indicates that the numbers are widely spread out, while a lower variance indicates they
are clustered closer to the mean
import numpy as np
a = [Link]([12,13,45,15,23,45,78,99])
print([Link](a))