Mobios v0.91

mobios.util
Class Histogram

java.lang.Object
  extended by mobios.util.Histogram

public class Histogram
extends Object

Given values, 1-d or 2-d, count the histogram

Version:
2006.05.31
Author:
Rui Mao

Nested Class Summary
static class Histogram.BinInfo
           
 
Constructor Summary
Histogram()
           
 
Method Summary
static double allPairs(String[] args)
           
static double allPairs(String[] args, boolean print)
           
static ArrayList<Histogram.BinInfo> completeOneDHistogram(double start, double width, double[] dist, int first, int last)
          Computes a one-dimensional histogram
static String continuousPivotSpaceHistogram(String[] args)
          Read a file consisting of coordiantes of points in pivot-space, i.e.
static String continuousPivotSpaceHistogram(String[] args, boolean print)
           
static void main(String[] args)
           
static double[][] oneDHistogram(double start, double width, double[] dist)
          Compute one-dimensional histogram
static void pivotSpaceHistogram(String[] args)
          Reads a file consisting of coordiantes of points in pivot-space, i.e.
static void pivotSpaceTwoDHistogram(String[] args)
          Read a file consisting of coordiantes of points in pivot-space, i.e.
static int[][] TwoDHist(double xMin, double xMax, int xSize, double[] xValue, double yMin, double yMax, int ySize, double[] yValue)
          Given the 2-d (x-y) values, ranges and number of bins, out put the (non-zero) number of occurances of each 2-d value.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Histogram

public Histogram()
Method Detail

completeOneDHistogram

public static ArrayList<Histogram.BinInfo> completeOneDHistogram(double start,
                                                                 double width,
                                                                 double[] dist,
                                                                 int first,
                                                                 int last)
Computes a one-dimensional histogram

Parameters:
start - the starting boundary of bins, bins can be left to this starting point.
width - width of bins, must be positive
dist - the array of distances to compute histogram
first - inclusive
last - exclusive
Returns:
a List of BinInfo, non-empty, non-overlaping. sorted asendingly by the center value.

oneDHistogram

public static double[][] oneDHistogram(double start,
                                       double width,
                                       double[] dist)
Compute one-dimensional histogram

Parameters:
start - the starting boundary of bins
width - width of bins
dist - the array of distances to compute histogram
Returns:
a 2-d double array of 2 rows. the first row is the upper bound of each bin, the second row is the corresponding bin size

TwoDHist

public static int[][] TwoDHist(double xMin,
                               double xMax,
                               int xSize,
                               double[] xValue,
                               double yMin,
                               double yMax,
                               int ySize,
                               double[] yValue)
Given the 2-d (x-y) values, ranges and number of bins, out put the (non-zero) number of occurances of each 2-d value. A large 2-d matrix will be used internally, therefore, might not work if numbers of bins are too large.

Parameters:
xMin - minimum value of x
xMax - maximum value of x
xSize - number of bins for x, or more accurately, how many parts the x value range will be divided into
xValue - values of x
yMin - minimum value of y
yMax - maximum value of y
ySize - number of bins for y, or more accurately, how many parts the y value range will be divided into
yValue - values of y
Returns:
the occurances //3-d vector, first row are x-values, second y-values, third row consists of occurances

pivotSpaceHistogram

public static void pivotSpaceHistogram(String[] args)
                                throws Exception
Reads a file consisting of coordiantes of points in pivot-space, i.e. distances to each pivot. the file should be a text file. The first part, separted by whitespace, of the first line should be a number, the number of pivots. then each following line is the description of a pivot, in the order. then an empty line. then, the first part of next line should be a number, number of points then each following line should be the coordinates of a point, separted by comma. in the command line, the first parameter should be the file name, then a series of numbers or chars, x0, x1, ..., xn, corresponding to dimensions d0, d1, ..., dn, less number of number/chars can be provided, they will start at dim 0, dims not specified will be ignored. if xi is '-', then dimension i is ignored, if xi is '.', then the histogram on dimension i will be computed, if xi is a number, then the value on dimension i should be fixed as that number, other values are ignored. min, max values of each dimension to compute histogram will be reported. if only one dimension to compute histogram, the histogram will be out put in one line, if two, then a matrix, if more, then each non-zero tuple will be output. the out put is to the screen.

Parameters:
args - the first should be the file name, then a series of numbers or chars, x0, x1, ..., xn, corresponding to dimensions d0, d1, ..., dn.
Throws:
Exception

pivotSpaceTwoDHistogram

public static void pivotSpaceTwoDHistogram(String[] args)
                                    throws Exception
Read a file consisting of coordiantes of points in pivot-space, i.e. distances to each pivot. The file format is the same as those required by other methods. the file should be a text file. The first part, separted by whitespace, of the first line should be a number, the number of pivots. then each following line is the description of a pivot, in the order. then an empty line. then, the first part of next line should be a number, number of points then each following line should be the coordinates of a point, separted by comma. in the command line, the first parameter should be the file name, the second and third should be sequential id of dimensions to compute histogram, start from 0. the output is the 2-d matrix histogram of the two designated dimensions the out put is to the screen.

Parameters:
args - the first should be the file name, the second and third should be sequential id of dimensions to compute histogram, start from 0.
Throws:
Exception

continuousPivotSpaceHistogram

public static String continuousPivotSpaceHistogram(String[] args)
                                            throws Exception
Read a file consisting of coordiantes of points in pivot-space, i.e. distances to each pivot. This distance values are real number, double/float the file should be a text file. The first part, separted by whitespace, of the first line should be a number, the number of pivots. then each following line is the description of a pivot, in the order. then an empty line. then, the first part of next line should be a number, number of points then each following line should be the coordinates of a point, separted by comma. in the command line, the first parameter should be the file name, then a series of sets of parameters for each dimension sequentially, if not enough sets of parameters are provided, later dimensions are ignored. a set of parameters for a dimension can be of one of the 3 formats: format 1: two double values separated by white space, means this dimension is fixed, in the range provided by the two doubles, first should not be larger than the second, left end inclusive, right end exclusive. format 2: "-", indicating this dimension is ignored format 3: "." followed by a number, indicating that this dimension is subject to histogram computation, and the number is the width of the bin. min, max values of each dimension to compute histogram will be reported. if only one dimension to compute histogram, the histogram will be out put in one line, if two, then a matrix, if more, then each non-zero tuple will be output. the out put is to the screen.

Parameters:
args - the first should be the file name, then width of bin. then a series of numbers or chars, x0, x1, ..., xn, corresponding to dimensions d0, d1, ..., dn.
Throws:
Exception

continuousPivotSpaceHistogram

public static String continuousPivotSpaceHistogram(String[] args,
                                                   boolean print)
                                            throws Exception
Throws:
Exception

allPairs

public static double allPairs(String[] args)
                       throws Exception
Throws:
Exception

allPairs

public static double allPairs(String[] args,
                              boolean print)
                       throws Exception
Throws:
Exception

main

public static void main(String[] args)
                 throws Exception
Throws:
Exception

Mobios v0.91

(C) 2002 - 2006 The MoBIoS Group