vec_math
Class DoubleHistogram

java.lang.Object
  extended by vec_math.DoubleHistogram
All Implemented Interfaces:
Histogram
Direct Known Subclasses:
CountHistogram

public class DoubleHistogram
extends Object
implements Histogram

From a list of doubles we calculate the histogram.


Field Summary
private  double av
          The average intensity as a double.
private  int[] counts
          The histogram bins.
static double DEFBINWIDTH
          Default bin width multiplicator in sigma.
private  double max
          The maximum intensity as a double.
private  double median
          The median intensity.
private  double min
          The minimum intensity as a float.
private  double mode
          The mode intensity.
private  int pixel
          The total number of pixel.
 
Constructor Summary
protected DoubleHistogram()
          Empty constructor.
protected DoubleHistogram(double _min, double _max, double _av, double _med, double _mode, int sum, int[] band)
          Counstructs with all specified.
protected DoubleHistogram(double _min, double _max, double _av, int sum, int[] band)
          Constructs a specified count histogram.
 
Method Summary
static Histogram createHistogram(double[] val, double width)
          Creates a histogram from a double array, specifying a bin width.
protected static Histogram createHistogram(double[] val, double width, double min, double max)
          Creates a histogram from known min and max values.
static Histogram createHistogram(Statistic s)
           
static Histogram createHistogram(Statistic s, double stdevbin)
          We create a histogram from the given statistic, calculating the bin width from the standard deviation of the statistic times the bin factor.
 boolean equals(Object what)
          To histograms are equal, if their data are equal.
static int findMedianIndex(int[] counts, double total)
          Scans a histogram array and returns the index, where half of the counts are to the left and half of the counts are to the right.
private static int findMedianIndex(int[] counts, double total, Vector1D frac)
          Scans a histogram array and returns the index, where half of the counts are to the left and half of the counts are to the right.
static int findModeIndex(int[] counts)
          Scans a histogram array and returns the most abundand index.
static double fractionMedianIndex(int[] counts, double sum)
          From the median index, which is the lowest index where at least 50% of the values lie to the left of it, we estimate a better fractional median index by splitting the median bin into fractions according to the population therein and return the fractional index such that truely 50% are to the left and right.
 double getAverage()
          Returns the intensity average.
 int[] getBinCounts()
          Returns the histogram itself.
 double getBinWidth()
          Return the bin width of the histogram in intensity.
 double getMax()
          Returns the intensity maximum.
 double getMedian()
          Returns the intensity median.
 double getMin()
          Returns the intensity minimum.
 double getMode()
          Returns the intensity mode.
 int getTotal()
          Return the total number of samples in this histogram.
static double parabolicModeIndex(int[] counts)
          From the mode index, we use the bin height to the left and right of it and calculate the parabolic mid-point from there, resulting in a more accurate mode position.
protected  void setAverage(double _av)
          Allows acces for daughter classes.
protected  void setBinCounts(int[] _counts)
          Allows acces for daughter classes.
protected  void setMax(double _max)
          Allows acces for daughter classes.
protected  void setMedian(double _median)
          Allows acces for daughter classes.
protected  void setMin(double _min)
          Allows acces for daughter classes.
protected  void setMode(double _mode)
          Allows acces for daughter classes.
protected  void setTotal(int totalCount)
          Allows acces for daughter classes.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFBINWIDTH

public static final double DEFBINWIDTH
Default bin width multiplicator in sigma.

See Also:
Constant Field Values

min

private double min
The minimum intensity as a float.


max

private double max
The maximum intensity as a double.


av

private double av
The average intensity as a double.


median

private double median
The median intensity.


mode

private double mode
The mode intensity.


pixel

private int pixel
The total number of pixel.


counts

private int[] counts
The histogram bins.

Constructor Detail

DoubleHistogram

protected DoubleHistogram()
Empty constructor.


DoubleHistogram

protected DoubleHistogram(double _min,
                          double _max,
                          double _av,
                          int sum,
                          int[] band)
Constructs a specified count histogram.


DoubleHistogram

protected DoubleHistogram(double _min,
                          double _max,
                          double _av,
                          double _med,
                          double _mode,
                          int sum,
                          int[] band)
Counstructs with all specified.

Method Detail

createHistogram

public static Histogram createHistogram(Statistic s)

createHistogram

public static Histogram createHistogram(Statistic s,
                                        double stdevbin)
We create a histogram from the given statistic, calculating the bin width from the standard deviation of the statistic times the bin factor.

Parameters:
s - The data, packed in a statistic
stdevbin - Bin width is stddev(s) time this value.

createHistogram

public static Histogram createHistogram(double[] val,
                                        double width)
Creates a histogram from a double array, specifying a bin width.


createHistogram

protected static Histogram createHistogram(double[] val,
                                           double width,
                                           double min,
                                           double max)
Creates a histogram from known min and max values. The width is a 'tentative' width, it is rescaled such that it fits an integer number of bins.


getMin

public double getMin()
Description copied from interface: Histogram
Returns the intensity minimum.

Specified by:
getMin in interface Histogram

getMax

public double getMax()
Description copied from interface: Histogram
Returns the intensity maximum.

Specified by:
getMax in interface Histogram

getAverage

public double getAverage()
Description copied from interface: Histogram
Returns the intensity average.

Specified by:
getAverage in interface Histogram

getMedian

public double getMedian()
Description copied from interface: Histogram
Returns the intensity median.

Specified by:
getMedian in interface Histogram

getMode

public double getMode()
Description copied from interface: Histogram
Returns the intensity mode.

Specified by:
getMode in interface Histogram

getBinWidth

public double getBinWidth()
Description copied from interface: Histogram
Return the bin width of the histogram in intensity.

Specified by:
getBinWidth in interface Histogram

getTotal

public int getTotal()
Description copied from interface: Histogram
Return the total number of samples in this histogram.

Specified by:
getTotal in interface Histogram

getBinCounts

public int[] getBinCounts()
Description copied from interface: Histogram
Returns the histogram itself. For each intensity level bin, this returns the number of pixel.

Specified by:
getBinCounts in interface Histogram

findMedianIndex

public static int findMedianIndex(int[] counts,
                                  double total)
Scans a histogram array and returns the index, where half of the counts are to the left and half of the counts are to the right.


findMedianIndex

private static int findMedianIndex(int[] counts,
                                   double total,
                                   Vector1D frac)
Scans a histogram array and returns the index, where half of the counts are to the left and half of the counts are to the right. If the last argument is not null, we put the fraction of points to the left in that Double.


findModeIndex

public static int findModeIndex(int[] counts)
Scans a histogram array and returns the most abundand index. This index is the array element index with the highest value.


parabolicModeIndex

public static double parabolicModeIndex(int[] counts)
From the mode index, we use the bin height to the left and right of it and calculate the parabolic mid-point from there, resulting in a more accurate mode position.


fractionMedianIndex

public static double fractionMedianIndex(int[] counts,
                                         double sum)
From the median index, which is the lowest index where at least 50% of the values lie to the left of it, we estimate a better fractional median index by splitting the median bin into fractions according to the population therein and return the fractional index such that truely 50% are to the left and right.


toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object what)
To histograms are equal, if their data are equal.

Overrides:
equals in class Object

setMin

protected void setMin(double _min)
Allows acces for daughter classes.


setMax

protected void setMax(double _max)
Allows acces for daughter classes.


setAverage

protected void setAverage(double _av)
Allows acces for daughter classes.


setMedian

protected void setMedian(double _median)
Allows acces for daughter classes.


setMode

protected void setMode(double _mode)
Allows acces for daughter classes.


setTotal

protected void setTotal(int totalCount)
Allows acces for daughter classes.


setBinCounts

protected void setBinCounts(int[] _counts)
Allows acces for daughter classes.