[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #45461] [octave forge] (statistics) binornd in
From: |
Michael Leitner |
Subject: |
[Octave-bug-tracker] [bug #45461] [octave forge] (statistics) binornd inefficient, patch attached |
Date: |
Thu, 25 Nov 2021 04:58:46 -0500 (EST) |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0 |
Follow-up Comment #2, bug #45461 (project octave):
Nice that this old patch gets attention!
I still have no mercurial, thus here is the necessary change in verbatim:
L = sum (k(:));
ind = repelems ((1 : L), [(1 : L); n(k)(:)'])';
p_ext = p(k)(ind)(:);
rnd(k) = accumarray (ind, rand (sum(n(k)(:)), 1) < p_ext);
has to be the content of the if...endif block that makes up the main part of
the patch. I took also the opportunity to tidy up the code by using accumarray
-- this should make it more performant, I hope, and also more readable.
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?45461>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/