Re: non-integer binsize [message #43862 is a reply to message #43857] |
Thu, 05 May 2005 09:44   |
JD Smith
Messages: 850 Registered: December 1999
|
Senior Member |
|
|
On Wed, 04 May 2005 17:28:04 -0700, patrick.gatlin wrote:
> This may be a very elementary question, but I was wondering if the
> histogram function can accept a binsize < 1?
>
> I am using the hist_2d function to determine the density field of some
> lat/lon locations in a dataset. These values range 4 deg lat and 4 deg
> lon. In order to determine the # of points per square km, I have setup
> the hist_2d function as follows:
>
> IDL> result=hist_2d(lon,lat,max1=lonmax,min1=lonmin,max2=latmax,$
> min2=latmin,bin1=1/111.,bin2=1/111.)
>
> where the size of bin1 and bin2 are the approximate conversions from km
> to degrees (1km=.09 deg).
> Since hist_2d needs two bins, then is the result equal the number of
> points within a box that is 1/111. long on all sides? Thus am assuming
> result will give me the # of points per square kilometer. Is this a
> correct assumption based upon the way hist_2d works?
If you peek inside HIST_2D (or HIST_ND for that matter), you'll see that
the way non-integer bin-sizes work is by first converting the data to some
suitable integer representation over the range of interest, typically
where the binsize is normalized to 1, and then taking the histogram. This
is also quite likely how HISTOGRAM itself works internally. You might
also like to read up on the rounding issues you can have when working
with floating point histograms:
http://www.dfanning.com/math_tips/razoredge.html
JD
|
|
|