[Top][All Lists]

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

RE: Modifications to hist.m

From: Lippert, Ross A.
Subject: RE: Modifications to hist.m
Date: Mon, 17 Mar 2003 08:45:57 -0500

I was recently helping someone at work here out with a faster
hist.  This one is simpler, but perhaps it is broken in some way
that others here will not want to use it.

I did something like this:
  if (size(y,1) == 1)
     [ans,I] = sort([y cutoff -inf]);
  elseif (size(y,2) == 1)
     [ans,I] = sort([y' cutoff -inf]);
     error("y must be a row or vector");

  freq = diff(find(I > length(y)))-1;
where cutoff is computed just as it was computed before and y is the given
data.  There are some +/- inf issues which may be problematic with the above
so perhaps one could instead do:
   [ans,I] = sort([y cutoff]);
   freq = diff( [0 find(I > length(y))]  ) - 1;
and get the same effect.

I figured that the extra log(n) of a C sort isn't really consequential.


-----Original Message-----
From: Paul Kienzle [mailto:address@hidden
Sent: Saturday, March 15, 2003 9:43 PM
To: Andy Adler
Cc: address@hidden
Subject: Re: Modifications to hist.m

Andy Adler wrote:

>I propose the following patch to hist.m;
>it results in about 2.5x speedup.
At one point a rewrote hist to not have any
loops.  I was doing a whole lot of really large
histograms (e.g., 100000 values drawn from
a poisson distribution --- I had to rewrite the
poisson generator too ;-)

Please check it out and tell me if it is any faster
than what you've got.  I think it might be slower
if you have a histogram with a lot of empty bins.


Paul Kienzle

reply via email to

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