[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Potential Addition: hist3
From: |
Jordi Gutiérrez Hermoso |
Subject: |
Re: Potential Addition: hist3 |
Date: |
Sun, 24 Jun 2012 08:23:43 -0400 |
On 24 June 2012 04:23, Daniel J Sebald <address@hidden> wrote:
> Yes, there may be some ways to speed up the code. In particular, this loop:
>
> for i = 1:length (X) %For each data point
> x_loc = find(x_bins > X(i,1))(1) - 1;
> y_loc = find(y_bins > X(i,2))(1) - 1;
> A(x_loc, y_loc) += 1;
> endfor
This looks like a prime candidate for accumarray:
http://www.gnu.org/software/octave/doc/interpreter/Accumulation.html
Note how it's used for histc.m:
http://hg.savannah.gnu.org/hgweb/octave/file/a922f768ee09/scripts/statistics/base/histc.m#l135
- Jordi G. H.