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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #34363] [octave forge] (statistics) Poor perfo


From: Nicholas Jankowski
Subject: [Octave-bug-tracker] [bug #34363] [octave forge] (statistics) Poor performance for hypergeometric distributions
Date: Fri, 5 Aug 2022 16:55:59 -0400 (EDT)

Follow-up Comment #17, bug #34363 (project octave):

ok. functions vectorized. fairly straightforward. I've attached a git patch as
well as the individual m files to this report.

the fixes rely on an optional "vectorexpand" parameter i added to hygepdf.
hygecdf, hygeinv, hygernd all made the same use of a vector v = 0:n(i), which
was the challenge identified in comment #14. that was simply worked around by
generating a single v = 0:max(n) vector and then after calculating the hygepdf
for each t,m,n set against that. then it was easy enough to only work with the
portion needed for each n(i). the hygepdf option returns a 2D array where each
pdf(i,j) is hygepdf(v(j), t(i),m(i),n(i)). 

after that it was just a matter of re-implementing the equivalent of lookup to
operate row-wise on the array (that would be a nice feature add to the current
lookup), and selecting the correct item from the list.

if adding the optional hygepdf parameter is undesired, it's likely possible to
incorporate those changes in each of the three files, or as an extra helper
file, but I think incorporating it in hygepdf is cleaner.

BISTs were added to hygepdf for the new option, vectorized versions of the
other functions still pass all tests. I didn't see any other tests needed on
those. 

quick speed tests show 3-10x improvement depending a lot on what's expanded. 


old looped functions

tic; for idx = 1:100, hygecdf(50,1000,400,[1:200]);endfor, toc
Elapsed time is 10.6302 seconds.

tic; for idx = 1:100, hygeinv(0.5,1000,[200:400],100);endfor, toc
Elapsed time is 11.9475 seconds.

tic; for idx = 1:100, hygernd(1000,[200:400],100);endfor, toc
Elapsed time is 9.30343 seconds.


new functions

tic; for idx = 1:100, hygecdf(50,1000,400,[1:200]);endfor, toc
Elapsed time is 1.48031 seconds.

tic; for idx = 1:100, hygeinv(0.5,1000,[200:400],100);endfor, toc
Elapsed time is 1.26353 seconds.

tic; for idx = 1:100, hygernd(1000,[200:400],100);endfor, toc
Elapsed time is 1.3026 seconds.


(file #53526, file #53527, file #53528, file #53529)

    _______________________________________________________

Additional Item Attachment:

File name: hygepdf.m                      Size:6 KB
    <https://file.savannah.gnu.org/file/hygepdf.m?file_id=53526>

File name: hygecdf.m                      Size:4 KB
    <https://file.savannah.gnu.org/file/hygecdf.m?file_id=53527>

File name: hygeinv.m                      Size:4 KB
    <https://file.savannah.gnu.org/file/hygeinv.m?file_id=53528>

File name: hygernd.m                      Size:5 KB
    <https://file.savannah.gnu.org/file/hygernd.m?file_id=53529>



    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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