Message268020
On Thu, Jun 09, 2016 at 09:24:04AM +0000, Mark Dickinson wrote:
> On the other hand, apparently `exp(mean(log(...)))` is good enough for SciPy:
Hmm, well, I don't have SciPy installed, but I've found that despite
their (well-deserved) reputation, numpy (and presumably scipy) often
have rather naive algorithms that can lose accuracy rather
spectacularly.
py> statistics.mean([1e50, 2e-50, -1e50, 2e-50])
1e-50
py> np.mean(np.array([1e50, 2e-50, -1e50, 2e-50]))
5e-51
py> statistics.mean([1e50, 2e-50, -1e50, 2e-50]*1000)
1e-50
py> np.mean(np.array([1e50, 2e-50, -1e50, 2e-50]*1000))
5.0000000000000002e-54
On the other hand, np is probably a hundred times (or more) faster, so I
suppose accuracy/speed makes a good trade off. |
|
Date |
User |
Action |
Args |
2016-06-09 11:59:05 | steven.daprano | set | recipients:
+ steven.daprano, rhettinger, mark.dickinson, cool-RR |
2016-06-09 11:59:05 | steven.daprano | link | issue27181 messages |
2016-06-09 11:59:04 | steven.daprano | create | |
|