Re: undersanding Histogram function

Hi Ricardo,

Your bins Linear1DSet has 11 bins, with the two end bins each
only covering half a bin interval. The sample values are actually
bin centers. So you'll get what you want with 10 evenly spaced
bins:

  Linear1DSet bins = new Linear1DSet(0.05, 0.95, 10);

This divides (0.0, 1.0) into 10 equal sized bins, with their
centers at 0.05, 0.15, ..., 0.95.

Cheers,
Bill

Ricardo Mantilla wrote:
> 
> Hi Bill and All,
> 
> I made this small program to test the Histogram function. what it does
> is to generate 10000 random numbers and get the histogram. I was
> expecting to have more or less the same number of points per bin but I
> am having only a half of the points in the first and last "interval".
> 
> May be I am either making a wrong interpretation of the results or I am
> giving the wrong input to the program.
> 
> Thanks again,
> Ricardo Mantilla
> University of Colorado at Boulder
> 
> import visad.*;
> import visad.java2d.DisplayImplJ2D;
> import java.rmi.RemoteException;
> import java.awt.Font;
> 
> public class testHisto extends java.lang.Object {
> 
>    /** Creates new testHisto */
>    public testHisto()  throws RemoteException, VisADException{
> 
> 
>        RealType numLinks = RealType.Generic;
>        RealType distanceToOut = RealType.Generic;
> 
>        FunctionType func_distanceToOut_numLinks = new
> FunctionType(distanceToOut, numLinks);
> 
>        Linear1DSet distanceToOut_set = new Linear1DSet(0, 1, 10000);
> 
>        float[][] NumL_vals = new float[1][10000];
>        for (int i=0;i<10000;i++) NumL_vals[0][i]=(float) Math.random();
> 
>        FlatField vals_ff = new FlatField( func_distanceToOut_numLinks,
> distanceToOut_set);
>        vals_ff.setSamples( NumL_vals );
> 
>        Linear1DSet bins = new Linear1DSet(0, 1, 11);
> 
>        FlatField hist = visad.math.Histogram.makeHistogram(vals_ff, bins);
> 
>        float[][] otra=bins.getSamples();
>        double[][] algo=hist.getValues();
> 
>        for (int i=0;i<algo[0].length;i++)
> System.out.println(otra[0][i]+" "+algo[0][i]);
> 
>    }
> 
>    /**
>    * @param args the command line arguments
>    */
>    public static void main (String args[]){
>        try{
>            new testHisto();
>        } catch (VisADException v){
>            System.err.println(v);
>        } catch (RemoteException r){
>            System.err.println(r);
>        }
>    }
> 
> }

-- 
----------------------------------------------------------
Bill Hibbard, SSEC, 1225 W. Dayton St., Madison, WI  53706
hibbard@xxxxxxxxxxxxxxxxx  608-263-4427  fax: 608-263-6738
http://www.ssec.wisc.edu/~billh/vis.html


  • 2001 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: