Question
What are some common aggregate functions provided by the Numpy module?
Answer
In addition to aggregates such as median
and standard deviation (std
), Numpy provides several other functions for aggregate statistics.
It provides functions for the area of order statistics, such as percentile
, which computes a percentile of data along a specified axis.
Numpy also provides a function to compute the average
along a specified axis.
It also provides a mean
function for getting the arithmetic mean along a specified axis.
Also, Numpy lets us compute the variance along a specified axis using var
.
Numpy provides many other helpful functions and methods, and you can check out the documentation for more information!
2 Likes
What is the purpose behind Numpy having an average
function as well as a mean
function? They seem to do exactly the same thing.
x = [1, 2, 3, 4, 5]
np.mean(x) // 3.0
np.average(x) // 3.0
2 Likes
Not sure if this answers your question, but it seems that mean and average are used interchangeably for the most part, with “mean” being the preferred term in statistics.
Here’s an excerpt from cuemath.com:
“Yes, most often average and mean are used interchangeably. In Statistics, instead of using the word average, the word mean is used. It does tend to create confusion as the basic meaning of both the words average and mean are the same.”
My guess is that Numpy has both mean() and average() as some individuals and industries prefer one term over the other. Including both is a way to make it convenient for everybody.
Sort of like how “gray” and “grey” are interchangeably.