-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Performance of numpy average and numpy.mean function #5507
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I did a quick timing using line_profiler: https://gist.github.com/Nodd/926e3e21af1f04741c14 28% of the time is spent doing The average function could use some refactoring :) |
I removed |
Excellent! That's not quite a complete fix (consider what happens if the input is Could you submit a pull request? -n
|
got finally fixed in #7382 |
I need a weightened average function on a VERY large Dataset (some 1e8 numbers or more). The numpy functions mean and average serve me well and fast, but I discovered, that numpy.average is slower than builing the weightened average myself with two numpy.mean functions, as shown by the example:
https://gist.github.com/skuschel/2d148a37a2ce17925fb0
np.average(a,weights=b)
takes 0.32 sec on my computer, butnp.mean(a*b)/np.mean(b)
takes 0.23 sec for the equally sized dataset, yielding the same result.How does that make sense?
The text was updated successfully, but these errors were encountered: