Java Reference
In-Depth Information
public int getTotal () {
int total = 0;
for (int i= 0; i < fNumBins; i++)
total += fBins[i];
return total;
}
/**
* Add an entry to a bin.
* @param x value added if it is in the range:<br>
*lo<= x < hi
**/
public void add (double x) {
if (x >= fHi) fOverflows++;
else if (x < fLo) fUnderflows++;
else {
double val = x fLo;
// Casting to int rounds off to lower
// integer value.
int bin = (int) (fNumBins * (val/fRange));
// Increment the corresponding bin.
fBins[bin]++;
}
}
/** Clear the histogram bins and the over and under flow
* counts. **/
public void clear () {
for (int i = 0; i < fNumBins; i++)
fBins[i] = 0;
fOverflows = 0;
fUnderflows = 0;
}
/**
* Provide access to the value in the bin element
* specified by bin - num. < br >
* Return the underflows if bin value negative,
* Return the overflows if bin value more than
* the number of bins.
**/
 
Search WWH ::




Custom Search