X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 16 Mar 2016 11:10 PM by  anon
HISTOGRAM function
 2 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
16 Mar 2016 11:10 PM
    Here is a example code mn = 0.8d mx = 1.5d step = 0.23d arr = [mn:mx:step] h = histogram(arr, min=mn, max=mx, binsize=step, loc=loc) print, h print, value_locate(loc, arr) The output of histogram function is wrong. Correct output is [1, 1, 1, 1]. This result is related to this post http://www.idlcoyote.com/math_tips/ra... Do you have any plane for fix this bug? -Thanks

    Deleted User



    Basic Member


    Posts:143
    Basic Member


    --
    08 Apr 2016 10:37 AM
    I don't think that this is a bug. I think that this is a consequence of the inexact nature of double precision numbers and the fact that you are trying create histograms where the data values and bin locations are the same. If you decrease the step size by a tiny amount, the correct result is returned. In addition, if you change a tiny amount to the minimum and maximum, the correct result will be returned. IDL> mx = 1.5d IDL> mn = 0.8d IDL> step = 0.23d IDL> arr = [mn:mx:step] IDL> hh = histogram(arr, binsize=step, loc=loc, min=mn-.0001d, max=mx+.0001d) IDL> print, hh 1 1 1 1 IDL> hh = histogram(arr, binsize=step-0.0000001d, loc=loc) IDL> print, hh 1 1 1 1 -David Starbuck Harris Geospatial Solutions

    Deleted User



    New Member


    Posts:
    New Member


    --
    09 Apr 2016 10:56 PM
    Yes, the "bug" is not exact wording. And your right, this is a consequence of the inexact nature of double precision numbers. The "bug" means problems of HISTOGRAM function algorithm. The HISTOGRAM function make a decide that the value of 1.03d( "arr[1]" in first writing) is smaller than 1.03d("loc[1]" in first writing). This is the problem. At least the example in the first writing, the result VALUE_LOCATE functin is correct(print, value_locate(loc, arr)). There is no problems. In the case of Python bridge. mn = 0.8d mx = 1.5d step = 0.23d arr = [mn:mx:step] h = histogram(arr, min=mn, max=mx, binsize=step, loc=loc) print, h ;; This is IDL histogram result 2 1 0 1 bins = [loc, loc[-1]] np = python.import('numpy') res = np.histogram(arr, bins=bins) print, res[0] ;; This Python result. 1, 1, 1, 1 The result of Python histogram function is correct. Thanks.
    You are not authorized to post a reply.