[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #56884] mean can overflow
From: |
Michael Leitner |
Subject: |
[Octave-bug-tracker] [bug #56884] mean can overflow |
Date: |
Tue, 17 Sep 2019 03:35:20 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0 |
Follow-up Comment #14, bug #56884 (project octave):
Thanks for testing. But please note that when we talk about performance, we
have to consider the following: Let's say we have x=randn(N,M), and we want to
take the mean over the first dimension. If both N and M are small, the
function invocation will take much longer than the actual evaluations, so this
is no issue. So the point is whether N or M (or both) are large. For
pairwise_mean, the computational effort should scale as N*M*log(N), for
iter_mean like N*(M+const), where I have written the time per loop iteration
explicitly. At my computer, const is about 2000, that is, only when the M
becomes larger than 2000, the cost of the looping starts to become
insignificant. Your example is such a case, you have M=201*202. So indeed, in
this case your code is faster. However, I would argue that most often (at
least for my use cases I can claim that) averages are taken over
one-dimensional arrays. And in this case, pairwise_mean is always (much)
faster. For instance, with N=100000 and M=1, I have 5 milliseconds for
pairwise_mean and 2.7 seconds for iter_mean.
Further, it seems to me that it is also more accurate. As neither mine nor
your algorithm as yet has any notion of object classes, a quick test is given
by
x=randn(10000,1);
double([iter_mean(single(x)) pairwise_mean(single(x))])-mean(x)
Here pairwise_mean seems to be more accurate by about an order of magnitude on
average, which I would expect to even increase for larger vectors.
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?56884>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [Octave-bug-tracker] [bug #56884] mean can overflow, (continued)
- [Octave-bug-tracker] [bug #56884] mean can overflow, Michael Godfrey, 2019/09/12
- [Octave-bug-tracker] [bug #56884] mean can overflow, Armin Müller, 2019/09/12
- [Octave-bug-tracker] [bug #56884] mean can overflow, Ceral Paquet, 2019/09/14
- [Octave-bug-tracker] [bug #56884] mean can overflow, Marco Caliari, 2019/09/16
- [Octave-bug-tracker] [bug #56884] mean can overflow, Michael Godfrey, 2019/09/16
- [Octave-bug-tracker] [bug #56884] mean can overflow, Michael Leitner, 2019/09/16
- [Octave-bug-tracker] [bug #56884] mean can overflow, Michael Leitner, 2019/09/16
- [Octave-bug-tracker] [bug #56884] mean can overflow, Michael Godfrey, 2019/09/16
- [Octave-bug-tracker] [bug #56884] mean can overflow, Michael Leitner, 2019/09/17
- [Octave-bug-tracker] [bug #56884] mean can overflow, Marco Caliari, 2019/09/17
- [Octave-bug-tracker] [bug #56884] mean can overflow,
Michael Leitner <=
- [Octave-bug-tracker] [bug #56884] mean can overflow, Marco Caliari, 2019/09/17
- [Octave-bug-tracker] [bug #56884] mean can overflow, Michael Leitner, 2019/09/17