org.strbio.math
Class Bin2D

java.lang.Object
  extended by org.strbio.math.IVector
      extended by org.strbio.math.Bin
          extended by org.strbio.math.Bin2D

public class Bin2D
extends Bin

This saves samples pairs of data, and remembers some stats about the y values for each bin.

  Version 1.2, 10/5/00 - added more stats
  Version 1.1, 4/1/99 - changed main() to not require min, max values...
    if not given, goes through the data twice
  Version 1.0, 9/29/98 - original version
  

Version:
1.2, 10/5/00
Author:
JMC

Field Summary
 Sampler[] bin_stats
           
protected  double sum_xy
           
 Sampler ySampler
           
 
Fields inherited from class org.strbio.math.Bin
binsize, min_v, nsamples, sum_x, sum_x2
 
Fields inherited from class org.strbio.math.IVector
data
 
Constructor Summary
Bin2D()
           
Bin2D(int nbins, double minv, double maxv)
          to set up the histogram-bin, you need to know the number of bins you want, the minimum possible value, and the maximum possible value of the data.
 
Method Summary
 double average(int whichBin)
          Average value sampled in a particular bin.
 double covar()
          Returns the covariance of values sampled.
 double[] linearFit()
          This will return the best linear fit of the sampled points.
 double maxSampled(int whichBin)
          Max value sampled in a particular bin.
 double minSampled(int whichBin)
          Min value sampled in a particular bin.
 double pearson()
          Returns the Pearson correlation coefficient R of values sampled.
 void print(Printf outfile)
          print out bins to an open Printf.
 int sample(double x, double y)
           
 double stdev(int whichBin)
          St dev of values sampled in a particular bin.
 
Methods inherited from class org.strbio.math.Bin
average, print, sample, samples, stdev, stdevp, zScore
 
Methods inherited from class org.strbio.math.IVector
add, add, cross, cross, dimension, dot, dot, eliminate, equals, length, load, load, max, min, multiply, multiply, multiply, reverse, reverse, save, save, setValue, setValueAt, sort, subtract, subtract, valueAt
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bin_stats

public Sampler[] bin_stats

ySampler

public Sampler ySampler

sum_xy

protected double sum_xy
Constructor Detail

Bin2D

public Bin2D(int nbins,
             double minv,
             double maxv)
to set up the histogram-bin, you need to know the number of bins you want, the minimum possible value, and the maximum possible value of the data. Sorry, but dynamically expanding bins would be a pain in the ass to write.

Parameters:
nbins - the number of bins to sort data into. You don't need any bins at all if you just want stats like average, stdev; use Sampler in this case.
minv - the minimum data you might sample
maxv - the maximum data you might sample

Bin2D

public Bin2D()
Method Detail

sample

public int sample(double x,
                  double y)

covar

public final double covar()
Returns the covariance of values sampled.


pearson

public final double pearson()
Returns the Pearson correlation coefficient R of values sampled.


linearFit

public final double[] linearFit()
This will return the best linear fit of the sampled points. This function returns an array of 2 doubles: the slope (m) and the y-intercept (b); the linear fit is y=mx+b


average

public double average(int whichBin)
Average value sampled in a particular bin.


stdev

public double stdev(int whichBin)
St dev of values sampled in a particular bin.


maxSampled

public double maxSampled(int whichBin)
Max value sampled in a particular bin.


minSampled

public double minSampled(int whichBin)
Min value sampled in a particular bin.


print

public void print(Printf outfile)
           throws java.io.IOException
print out bins to an open Printf. For each bin, this prints the min, center, and maximum bounds of the bin, and the number of values that were sampled in it.

Overrides:
print in class Bin
Throws:
java.io.IOException
See Also:
IVector.save(org.strbio.io.Printf)