Search code examples
plothistogrammedianidl

IDL - calculating Median


How to calculate a median for the histogram below? The "n_p" variable is double and the "np_omni" variable is float. But I am not sure what the "h" variable represents. I am still confused about the data types.

enter image description here

enter image description here


Solution

  • The output of HISTOGRAM is an [N]-element array of counts for an [N]-element array of bin locations (i.e., the LOCATIONS keyword you used). If you use the MEDIAN function on h, the result would be the median of the counts in all these bins, not the median of the n_p variable. To find the median of the n_p variable, do the following:

    npmd = MEDIAN(n_p)
    

    (or include the array of indices from ind if you only want that subset of values to calculate the median)

    The float and double datatypes refer to single- and double-precision floating point numbers.