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 10:59:58 -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 #14, bug #60539 (project octave):

Is there a way to be even smarter about the initial guess?  I changed the
reporting code to show the initial guess X0 on entrance to the subfunction
newton_method.  I labeled this as iter #0.  I then tried the difficult value 1
- 1e-6.  Results are below.


xtst = 1 - 1e-6
xtst = 0.999999000000000
biinv3 (xtst, 2, 4)
iter: 0, x: 0.25
iter: 1, # todo: 1, x: 0.549999525925926, max (df): 0.299999525925926
iter: 2, # todo: 1, x: 0.680907792380916, max (df): 0.13090826645499
iter: 3, # todo: 1, x: 0.768155355469287, max (df): 0.0872475630883709
iter: 4, # todo: 1, x: 0.829610060942496, max (df): 0.0614547054732095
iter: 5, # todo: 1, x: 0.873945144205887, max (df): 0.0443350832633909
iter: 6, # todo: 1, x: 0.906339380982877, max (df): 0.0323942367769896
iter: 7, # todo: 1, x: 0.93017133347546, max (df): 0.0238319524925828
iter: 8, # todo: 1, x: 0.94773273239768, max (df): 0.0175613989222206
iter: 9, # todo: 1, x: 0.960574192526131, max (df): 0.0128414601284503
iter: 10, # todo: 1, x: 0.969662183290227, max (df): 0.00908799076409684
iter: 11, # todo: 1, x: 0.975447395458917, max (df): 0.00578521216868909
iter: 12, # todo: 1, x: 0.97815327971624, max (df): 0.00270588425732304
iter: 13, # todo: 1, x: 0.978737006399498, max (df): 0.000583726683258333
iter: 14, # todo: 1, x: 0.97876173884375, max (df): 2.47324442522867e-05
iter: 15, # todo: 1, x: 0.978761781799343, max (df): 4.29555923286543e-08
ans = 0.978761781799343


The initial guess is set to the point of inflection.  I plotted the function
F(2,4) to see the shape (inflection is at 0.25 as promised) and the minimum is
off to the right.  Is it possible to know, in advance, whether the minimum is
left or right of the inflection point and thus perform an initial bisection
step?

In this case, the algorithm starts at 0.25 and has climb all the way to 0.978
which requires 15 iterations.  Just to test my idea, I set a breakpoint in the
newton_method subfunction and set the initial guess to be the bisection
between 0.25 and 1 or 0.625.  When I then use 'dbcont' to continue execution
the convergence is faster, but by only 1 iteration so perhaps it is not worth
it given the extra complexity that would be required.


iter: 0, x: 0.625
iter: 1, # todo: 1, x: 0.729998482962963, max (df): 0.104998482962963
iter: 2, # todo: 1, x: 0.802488599632329, max (df): 0.0724901166693664
iter: 3, # todo: 1, x: 0.854288974392737, max (df): 0.0518003747604075
iter: 4, # todo: 1, x: 0.891940465698917, max (df): 0.0376514913061801
iter: 5, # todo: 1, x: 0.919565498856449, max (df): 0.0276250331575323
iter: 6, # todo: 1, x: 0.939921418392225, max (df): 0.0203559195357758
iter: 7, # todo: 1, x: 0.954887758751933, max (df): 0.0149663403597078
iter: 8, # todo: 1, x: 0.965702041241923, max (df): 0.0108142824899903
iter: 9, # todo: 1, x: 0.973054155601817, max (df): 0.00735211435989399
iter: 10, # todo: 1, x: 0.977201545731428, max (df): 0.00414739012961038
iter: 11, # todo: 1, x: 0.978609883222818, max (df): 0.00140833749138997
iter: 12, # todo: 1, x: 0.978760183041749, max (df): 0.000150299818931775
iter: 13, # todo: 1, x: 0.978761781620095, max (df): 1.59857834568065e-06
iter: 14, # todo: 1, x: 0.978761781799482, max (df): 1.79387267097812e-10
ans = 0.978761781799482



(file #51484)
    _______________________________________________________

Additional Item Attachment:

File name: F(2,4).png                     Size:25 KB
    <https://file.savannah.gnu.org/file/F(2,4).png?file_id=51484>



    _______________________________________________________

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]