hist.m can handle only one column when nbins > 29
John W. Eaton
jwe at bevo.che.wisc.edu
Thu Mar 6 12:44:30 CST 2008
On 6-Mar-2008, Robert S. Mahurin wrote:
| When hist.m is asked to produce a histogram with 30 or more bins, it
| uses a "more efficient" algorithm whos implementation contains a size
| error.
| Beginning hist.m line 107:
|
| else
| ## The following algorithm works fastest for n greater than about 30.
| ## Put cutoff elements between boundaries, integrate over all
| ## elements, keep totals at boundaries.
| ### [s, idx] = sort ([y; cutoff]);
| [s, idx] = sort ([y; repmat(cutoff, 1, columns (y))]);
| len = rows (y);
| chist = cumsum (idx <= len);
| t1 = zeros (1, columns (y));
| ### t2 = reshape (chist(idx > len), size (cutoff));
| t2 = reshape (chist(idx > len), rows (cutoff), columns (y));
| t3 = chist(end,:) - sum (isnan (y));
| chist = [t1; t2; t3];
| endif
|
| Also, eliminating the temporaries t1,t2,t3 seems to reduce memory
| usage by eliminating some irrelevant matrix reference. If I replace
| the code between the two chist assignments with
|
| chist = cumsum (idx <= len);
| chist = [zeros(1, columns (y)); \
| reshape(chist(idx > len), rows (cutoff), columns (y)); \
| chist(end,:) - sum(isnan (y));];
I made the following changes.
Thanks,
jwe
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: diffs
Url: https://www.cae.wisc.edu/pipermail/bug-octave/attachments/20080306/07061d78/attachment-0001.ksh
More information about the Bug-octave
mailing list