[Numpy-discussion] 2d binning and linear regression

Tom Durrant thdurrant@gmail....
Sun Jun 20 21:57:45 CDT 2010


> 
> are you doing something like np.polyfit(model, obs, 1) ?
> 
> If you are using polyfit with deg=1, i.e. fitting a straight line,
> then this could be also calculated using the weights in histogram2d.
> 
> histogram2d (histogramdd) uses np.digitize and np.bincount, so I'm
> surprised if the histogram2d version is much faster. If a quick
> reading of histogramdd is correct, the main improvement would be to
> get the labels "xy" out of it, so it can be used repeatedly with
> np.bincount.
> 
> Josef
> 
Thanks Josef, 

>From my limited understanding, you are right the histogram is much faster due to 
the fact that it doesn't have to keep reading in the array over and over....

I am using np.polyfit(model, obs, 1).  I couldn't work out a way to do these 
regression using histogram2d and weights, but you think it can be done?  This 
would be great!

Cheers
Tom
 






More information about the NumPy-Discussion mailing list