[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #60539] Slow performance of betaincinv.m
From: |
Rik |
Subject: |
[Octave-bug-tracker] [bug #60539] Slow performance of betaincinv.m |
Date: |
Fri, 7 May 2021 12:25:45 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.72 Safari/537.36 |
Follow-up Comment #2, bug #60539 (project octave):
I instrumented the code to see where some of the hots spots were. I then ran
with a random 1 million point sample.
y = betaincinv (rand (1e6,1), 1, 3);
In the newton_method() function I put separate timings around the the range
checking code and around the actual objective function calls
tic;
x(x(todo) < 0) = eps;
x(x(todo) > 1) = 1-eps;
bm1(it) = toc;
tic;
res(todo) = -F(x(todo), a(todo), b(todo), y(todo)) ...
./ JF (x(todo), a(todo), b(todo));
bm2(it) = toc;
The bisection() and newton_method() functions are called twice for the lower
tail and upper tail. The results were
bm_bisect: 1.36663
bm1: 0.0612214
bm2: 1.36306
bm_bisect: 1.50331
bm1: 0.0524464
bm2: 1.32451
Lots to optimize, or not, here. First, performance of the code to do range
checking is immaterial (25X smaller) compared to objective function
evaluations.
Second, the code performs 10 rounds of bisection followed by 20 rounds of
Newton's Methods. The bisection starts with initial values of 0, 1 so that
the center of the first round will be 0.5. Given that Newton's method will
converge faster than bisection, I think we could just skip this step entirely
and start with an initial guess of 0.5 for the solution. Handily, the
bisection function accepts a parameter for number of iterations. I set that
to 1 and then re-ran the function. The calculated output differed slightly
from the original run, but the maximum deviation was 2 eps which I think is
acceptable.
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?60539>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [Octave-bug-tracker] [bug #60539] Slow performance of betaincinv.m, Rik, 2021/05/06
- [Octave-bug-tracker] [bug #60539] Slow performance of betaincinv.m, Michael Leitner, 2021/05/06
- [Octave-bug-tracker] [bug #60539] Slow performance of betaincinv.m,
Rik <=
- [Octave-bug-tracker] [bug #60539] Slow performance of betaincinv.m, Rik, 2021/05/07
- [Octave-bug-tracker] [bug #60539] Slow performance of betaincinv.m, Michael Leitner, 2021/05/07
- [Octave-bug-tracker] [bug #60539] Slow performance of betaincinv.m, Rik, 2021/05/10
- [Octave-bug-tracker] [bug #60539] Slow performance of betaincinv.m, Michael Leitner, 2021/05/13
- [Octave-bug-tracker] [bug #60539] Slow performance of betaincinv.m, Rik, 2021/05/13
- [Octave-bug-tracker] [bug #60539] Slow performance of betaincinv.m, Rik, 2021/05/14
- [Octave-bug-tracker] [bug #60539] Slow performance of betaincinv.m, Rik, 2021/05/25
- [Octave-bug-tracker] [bug #60539] Slow performance of betaincinv.m, Dmitri A. Sergatskov, 2021/05/25
- [Octave-bug-tracker] [bug #60539] Slow performance of betaincinv.m, Rik, 2021/05/25
- [Octave-bug-tracker] [bug #60539] Slow performance of betaincinv.m, Michael Leitner, 2021/05/26