-
-
Notifications
You must be signed in to change notification settings - Fork 12.2k
Performance of numpy average and numpy.mean function #5507
Copy link
Copy link
Closed
Description
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, but
np.mean(a*b)/np.mean(b) takes 0.23 sec for the equally sized dataset, yielding the same result.
How does that make sense?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels