octave-bug-tracker
[Top][All Lists]
Advanced

[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: Thu, 27 May 2021 19:14:34 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36

Follow-up Comment #16, bug #60539 (project octave):

For reference, since we are getting different results, I attach newbeta.m and
biinv3.m.  The first file is your code with the only addition being the
reporting of each iteration in the newton_method subfunction.  The second file
contains my change to eliminate df/df_new variables and to change the stopping
criteria to eps.  Hopefully the issue then becomes reproducible on your
machine with badx = 5.717842473940138e-07.

Your tests indicate a problem with betainc.  Can you file a new bug report
about that function and that specific issue?

Since it is uncertain when the issue above will be fixed, I think we need to
code defensively in betaincinv.m.  My suggestions of eps (or maybe eps/2)
works.  I also implemented your suggestion of looking for the delta in the
variable "step" to fall to zero.  I did this by storing the last round's step
values in the variable old_step and then calculating


    ind = abs (step - old_step) > 0;


This is attached as biinv4.m.  It works, but it doesn't seem to result in any
extra precision for the test case I mentioned.  I ran biinv3.m and then
biinv4.m and got


iter: 0, x: 0.25
iter: 1, # todo: 1, x: 0.0759261969940135, max (df): 0.174073803005986
iter: 2, # todo: 1, x: 0.0347141003450014, max (df): 0.0412120966490121
iter: 3, # todo: 1, x: 0.0167224581112431, max (df): 0.0179916422337583
iter: 4, # todo: 1, x: 0.00821961591239634, max (df): 0.00850284219884681
iter: 5, # todo: 1, x: 0.0040791709326122, max (df): 0.00414044497978414
iter: 6, # todo: 1, x: 0.00203830950551201, max (df): 0.00204086142710019
iter: 7, # todo: 1, x: 0.00103118309152024, max (df): 0.00100712641399177
iter: 8, # todo: 1, x: 0.000542869669144377, max (df): 0.000488313422375863
iter: 9, # todo: 1, x: 0.000324036344981909, max (df): 0.000218833324162468
iter: 10, # todo: 1, x: 0.000250279883120058, max (df): 7.3756461861851e-05
iter: 11, # todo: 1, x: 0.00023942338681535, max (df): 1.08564963047085e-05
iter: 12, # todo: 1, x: 0.000239177433992639, max (df): 2.45952822710538e-07
iter: 13, # todo: 1, x: 0.000239177307623453, max (df): 1.26369186577854e-10
ans = 2.391773076234193e-04

iter: 0, x: 0.25
iter: 1, # todo: 1, x: 0.0759261969940135, max (df): 0.174073803005986
iter: 2, # todo: 1, x: 0.0347141003450014, max (df): 0.0412120966490121
iter: 3, # todo: 1, x: 0.0167224581112431, max (df): 0.0179916422337583
iter: 4, # todo: 1, x: 0.00821961591239634, max (df): 0.00850284219884681
iter: 5, # todo: 1, x: 0.0040791709326122, max (df): 0.00414044497978414
iter: 6, # todo: 1, x: 0.00203830950551201, max (df): 0.00204086142710019
iter: 7, # todo: 1, x: 0.00103118309152024, max (df): 0.00100712641399177
iter: 8, # todo: 1, x: 0.000542869669144377, max (df): 0.000488313422375863
iter: 9, # todo: 1, x: 0.000324036344981909, max (df): 0.000218833324162468
iter: 10, # todo: 1, x: 0.000250279883120058, max (df): 7.3756461861851e-05
iter: 11, # todo: 1, x: 0.00023942338681535, max (df): 1.08564963047085e-05
iter: 12, # todo: 1, x: 0.000239177433992639, max (df): 2.45952822710538e-07
iter: 13, # todo: 1, x: 0.000239177307623453, max (df): 1.26369186577854e-10
iter: 14, # todo: 1, x: 0.000239177307623419, max (df): 3.31805682026064e-17
iter: 15, # todo: 1, x: 0.000239177307623419, max (df): 2.21499120177644e-20
ans = 2.391773076234193e-04


The answers are identical, but the second stopping criteria took 2 more
iterations to get there.

I'm not sure I correctly understand the test case you wanted, but I tried
x=1e-4, A = 4, B = 4 with your original code (newbeta) and with mine
(biinv3).


format long
newbeta (1e-4, 4, 4)
ans = 4.218405600470292e-02
biinv3 (1e-4, 4, 4)
ans = 4.218405600470292e-02


The answers are identical.

Finally, it was just a thought, but I agree it doesn't seem worth trying to
implement any bisection step.

(file #51486, file #51487)
    _______________________________________________________

Additional Item Attachment:

File name: newbeta.m                      Size:9 KB
    <https://file.savannah.gnu.org/file/newbeta.m?file_id=51486>

File name: biinv3.m                       Size:9 KB
    <https://file.savannah.gnu.org/file/biinv3.m?file_id=51487>



    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?60539>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]