Next: Function: is_gaussian() Up: GRASP Routines: General purpose Previous: Function: avg_spec()   Contents

## Function: binshort()

0 void binshort(short *input,int ninput,double *bins,int offset)
This function performs the ``binning" which is needed to study the statistics of an array of short integers, such as the output of a 12 or 16 bit analog-to-digitial converter. Its output is a histogram showing the number of times that a particular value occurred in an input array. Note that this routine increments the output histogram, so that you can use it for accumulating statistics of a particular variable.

The arguments are:

input: Input. This routine makes a histogram of the values input[0..ninput-1].
ninput: Input. The number of elements in the previous array.
bins: Output. Upon return from the function, this array contains a histogram showing the probability distribution of the values input[0..ninput-1]. The array element bins[offset] is incremented by the number of elements of input[] that had value . The array element bins[offset+i] is incremented by the number of elements of input[] that had value . If the output of your 16 bit ADC ranges from -32,768 to +32,767 and nbins has value then you would want . For a 12-bit ADC you would probably want , and depending upon the sign conventions either or .
offset: Input. The offset defined above.

Note that in the interests of speed and efficiency this routine does not check that your values lie within range. So if you try to bin a value that lies outside of the range you may end up over-writing another array! You'll then spend unhappy hours trying to locate the source of bizzare unpredictable behavior in your code, when you could be doing better things, like seeing if your ADC has dynamic range problem (reaches the end-point values too often) or has a mean value of zero (even with AC-coupled inputs the ADC may have substantial DC offset).

Authors: Bruce Allen, ballen@dirac.phys.uwm.edu