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: Tue, 25 May 2021 19:44:43 -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 #9, bug #60539 (project octave):

This seems much faster, but I have some concerns about accuracy.

First, I modified the newton_method subfunction to report on its progress. 
The modified code is attached as biinv.m (BetaIncINV.m).


  iter = 1;
  while (length (todo) > 0)
    printf ("iter: %d, # todo: %d, x: %.15g, max (df): %.15g\n", iter++, numel
(todo), x, max (abs (df(:))));


I then ran some difficult values through it and checked the results against
Matlab.  For example,


biinv (single (1-1e-6), 2, 4)
iter: 1, # todo: 1, x: 0.549999475479126, max (df): 0.299999475479126
iter: 2, # todo: 1, x: 0.680907785892487, max (df): 0.130908310413361
iter: 3, # todo: 1, x: 0.76815539598465, max (df): 0.0872476100921631
iter: 4, # todo: 1, x: 0.829610109329224, max (df): 0.061454713344574
iter: 5, # todo: 1, x: 0.873944878578186, max (df): 0.0443347692489624
iter: 6, # todo: 1, x: 0.906338155269623, max (df): 0.0323932766914368
iter: 7, # todo: 1, x: 0.930169761180878, max (df): 0.0238316059112549
iter: 8, # todo: 1, x: 0.947727501392365, max (df): 0.0175577402114868
iter: 9, # todo: 1, x: 0.960563063621521, max (df): 0.0128355622291565
iter: 10, # todo: 1, x: 0.969668209552765, max (df): 0.0091051459312439
iter: 11, # todo: 1, x: 0.975395321846008, max (df): 0.00572711229324341
iter: 12, # todo: 1, x: 0.97806191444397, max (df): 0.00266659259796143
iter: 13, # todo: 1, x: 0.978639125823975, max (df): 0.000577211380004883
ans = 0.9786391


The result in Matlab is 0.9786913.  The last 3 digits are different.

Also, could this code be shortened?


    step = -F (x(todo), a(todo), b(todo), y(todo)) ./ ...
       JF (x(todo), a(todo), b(todo), Bln(todo));
    df_new = (x(todo) + step) - x(todo);
    x(todo) += step;


It seems like df_new is just equal to the existing variable step.


df_new = (x + step) - x
       =  x + step - x
       =  x - x + step
       = step




(file #51480)
    _______________________________________________________

Additional Item Attachment:

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



    _______________________________________________________

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]