org.strbio.math
Class FBin

java.lang.Object
  extended by org.strbio.math.IVector
      extended by org.strbio.math.FBin

public class FBin
extends IVector

a class which does 1-D histogram-FBins. If you're sampling some (float) data and want stats like average, stdev on the ensemble, but don't want to bother keeping track of every point, this should be useful. If you do want to keep track of every point, try using a DVector or DMatrix, which have similar stats functions.

 Version 1.2, 6/24/99 - added main() to sample from a file.
 Version 1.1, 9/29/98 - sample()
   is no longer final, and PrintfStream changed to Printf.
   Fixed average and stdev to return NaN when not enough samples.
   Sample() now returns an int, indicating the FBin it was put
   into.
 Version 1.0, 3/31/98 - original version.
 

Version:
1.2, 6/24/99
Author:
JMC

Field Summary
protected  float FBinsize
           
protected  float min_v
           
protected  int nsamples
           
protected  float sum_x
           
protected  float sum_x2
           
 
Fields inherited from class org.strbio.math.IVector
data
 
Constructor Summary
FBin(int nFBins, float minv, float maxv)
          to set up the histogram-FBin, you need to know the number of FBins you want, the minimum possible value, and the maximum possible value of the data.
 
Method Summary
 float average()
          Return the average of all values sampled.
 void print(Printf outfile)
          print out FBins to an open Printf.
 void print(java.lang.String filename)
          print out FBins to a new file.
 int sample(float r)
          Sample a value.
 int samples()
          how many values have I sampled?
 float stdev()
          Return the standard deviation of all values sampled.
 
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

min_v

protected float min_v

FBinsize

protected float FBinsize

sum_x

protected float sum_x

sum_x2

protected float sum_x2

nsamples

protected int nsamples
Constructor Detail

FBin

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

Parameters:
nFBins - the number of FBins to sort data into. You don't need any FBins at all if you just want stats like average, stdev.
minv - the minimum data you might sample
maxv - the maximum data you might sample
Method Detail

sample

public int sample(float r)
Sample a value. If the value is lower than the minimum value you specified in setting up the FBin, the sample goes into the lowest FBin. Same thing goes for the high end. This 'rounding off' does not affect statistics like the average.


average

public final float average()
Return the average of all values sampled.


stdev

public final float stdev()
Return the standard deviation of all values sampled. This is the 'sample' standard deviation.


samples

public final int samples()
how many values have I sampled?


print

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

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

print

public final void print(java.lang.String filename)
                 throws java.io.IOException
print out FBins to a new file. For each FBin, this prints the min, center, and maximum bounds of the FBin, and the number of values that were sampled in it.

Parameters:
filename - the file name. Overwrites existing files.
Throws:
java.io.IOException