USGS

Isis 3.0 Object Programmers' Reference

Home

Isis::Statistics Class Reference

This class is used to accumulate statistics on double arrays. More...

#include <Statistics.h>

Inheritance diagram for Isis::Statistics:
Inheritance graph
Collaboration diagram for Isis::Statistics:
Collaboration graph

Public Member Functions

 Statistics ()
 Constructs an IsisStats object with accumulators and counters set to zero.
 
 ~Statistics ()
 Destroys the IsisStats object.
 
void Reset ()
 Reset all accumulators and counters to zero.
 
void AddData (const double *data, const unsigned int count)
 Add an array of doubles to the accumulators and counters.
 
void AddData (const double data)
 Add a double to the accumulators and counters.
 
void RemoveData (const double *data, const unsigned int count)
 Remove an array of doubles from the accumulators and counters.
 
void RemoveData (const double data)
 
void SetValidRange (const double minimum=Isis::ValidMinimum, const double maximum=Isis::ValidMaximum)
 
double ValidMinimum () const
 
double ValidMaximum () const
 
bool InRange (const double value)
 
bool AboveRange (const double value)
 
bool BelowRange (const double value)
 
double Average () const
 Computes and returns the average.
 
double StandardDeviation () const
 Computes and returns the standard deviation.
 
double Variance () const
 Computes and returns the variance.
 
double Rms () const
 Computes and returns the rms.
 
double Minimum () const
 Returns the absolute minimum double found in all data passed through the AddData method.
 
double Maximum () const
 Returns the absolute maximum double found in all data passed through the AddData method.
 
double ChebyshevMinimum (const double percent=99.5) const
 This method returns a minimum such that X percent of the data will fall with K standard deviations of the average (Chebyshev's Theorem).
 
double ChebyshevMaximum (const double percent=99.5) const
 This method returns a maximum such that X percent of the data will fall with K standard deviations of the average (Chebyshev's Theorem).
 
double BestMinimum (const double percent=99.5) const
 This method returns the better of the absolute minimum or the Chebyshev minimum.
 
double BestMaximum (const double percent=99.5) const
 This method returns the better of the absolute maximum or the Chebyshev maximum.
 
double ZScore (const double value) const
 This method returns the better of the z-score of the given value.
 
BigInt TotalPixels () const
 Returns the total number of pixels processed (valid and invalid).
 
BigInt ValidPixels () const
 Returns the total number of valid pixels processed.
 
BigInt OverRangePixels () const
 Returns the total number of pixels over the valid range encountered.
 
BigInt UnderRangePixels () const
 Returns the total number of pixels under the valid range encountered.
 
BigInt NullPixels () const
 Returns the total number of NULL pixels encountered.
 
BigInt LisPixels () const
 Returns the total number of low instrument saturation (LIS) pixels encountered.
 
BigInt LrsPixels () const
 Returns the total number of low representation saturation (LRS) pixels encountered.
 
BigInt HisPixels () const
 Returns the total number of high instrument saturation (HIS) pixels encountered.
 
BigInt HrsPixels () const
 Returns the total number of high representation saturation (HRS) pixels encountered.
 
BigInt OutOfRangePixels () const
 Returns the total number of pixels outside of the valid range encountered.
 
double Sum () const
 Returns the sum of all the data.
 
double SumSquare () const
 Returns the sum of all the squared data.
 

Private Attributes

double p_sum
 Sum accumulator.
 
double p_sumsum
 Sum-squared accumulator.
 
double p_minimum
 Minimum double value encountered.
 
double p_maximum
 Maximum double value encountered.
 
double p_validMinimum
 Minimum valid pixel value.
 
double p_validMaximum
 Maximum valid pixel value.
 
BigInt p_totalPixels
 Count of total pixels processed.
 
BigInt p_validPixels
 Count of valid pixels (non-special) processed.
 
BigInt p_nullPixels
 Count of null pixels processed.
 
BigInt p_lrsPixels
 Count of low instrument saturation pixels processed.
 
BigInt p_lisPixels
 Count of low representation saturation pixels processed.
 
BigInt p_hrsPixels
 Count of high instrument saturation pixels processed.
 
BigInt p_hisPixels
 Count of high instrument representation pixels processed.
 
BigInt p_underRangePixels
 Count of pixels less than the valid range.
 
BigInt p_overRangePixels
 Count of pixels greater than the valid range.
 
bool p_removedData
 
   Indicates the RemoveData method was called which implies

p_minimum and p_maximum are invalid.

 

Detailed Description

This class is used to accumulate statistics on double arrays.

This class is used to accumulate statistics on double arrays. In particular, it is highly useful for obtaining statistics on cube data. Parameters which can be computed are 1) average, 2) standard deviation, 3) variance, 4) minimum, 5) maximum and 6) various counts of valid and/or special pixels.

The following example shows a simple set up and usage of the Statistics class to calculate the average of a set of values:

Statistics myStats ;
double myData [] = { 1.0, 3.0, 2.4, 7.5 } ;
myStats.AddData (myData, 4) ;
double myAverage = myStats.Average () ;
cout << "The average of the data is " << myAverage << endl ;

For an example of how the Statistics object is used in Isis, see the Histogram object (inherits from Statistics) and the stats application, stats.cpp (uses the Statistics child class Histogram).

Author
2002-05-06 Jeff Anderson
History:

2002-05-08 Jeff Anderson - Added Chebyshev and Best minimum/maximum methods.

2004-05-11 Jeff Anderson - Moved Reset, AddData and RemoveData methods into public space.

2004-06-28 Jeff Anderson - Added Sum and SumSquare methods.

2005-02-17 Deborah Lee Soltesz - Modified file to support Doxygen documentation.

2005-05-23 Jeff Anderson - Changed to support 2GB+ files

2006-02-15 Jacob Danton - Added Valid Range options/methods

2006-03-10 Jacob Danton - Added Z-score method

2007-01-18 Robert Sucharski - Added AddData method for a single double value

2008-05-06 Steven Lambright - Added AboveRange, BelowRange methods

2010-03-18 Sharmila Prasad - Error message more meaningful for SetValidRange function

2011-06-13 Ken Edmundson - Added Rms method

Todo:
2005-02-07 Deborah Lee Soltesz - add example using cube data to the class documentation

Definition at line 78 of file Statistics.h.

Constructor & Destructor Documentation

Isis::Statistics::Statistics ( )

Constructs an IsisStats object with accumulators and counters set to zero.

Definition at line 30 of file Statistics.cpp.

Isis::Statistics::~Statistics ( )

Destroys the IsisStats object.

Definition at line 54 of file Statistics.cpp.

Member Function Documentation

void Isis::Statistics::AddData ( const double  data)
inline

Add a double to the accumulators and counters.

This method can be invoked multiple times (for example: once for each pixel in a cube) before obtaining statistics.

Parameters
dataThe data to be added to the data set used for statistical calculations.

Definition at line 94 of file Statistics.h.

References Isis::IsHisPixel(), Isis::IsHrsPixel(), Isis::IsLisPixel(), Isis::IsLrsPixel(), Isis::IsNullPixel(), Isis::IsValidPixel(), p_hisPixels, p_hrsPixels, p_lisPixels, p_lrsPixels, p_maximum, p_minimum, p_nullPixels, p_overRangePixels, p_sum, p_sumsum, p_totalPixels, p_underRangePixels, and p_validPixels.

double Isis::Statistics::BestMaximum ( const double  percent = 99.5) const

This method returns the better of the absolute maximum or the Chebyshev maximum.

The better value is considered the value closest to the mean.

Parameters
percentThe probability that the maximum is within K standard deviations of the mean (Used to compute the Chebyshev maximum). Default value = 99.5.
Returns
Best of absolute and Chebyshev maximums
See Also
Statistics::Maximum Statistics::ChebyshevMaximum

Definition at line 427 of file Statistics.cpp.

Referenced by Isis::ChipViewport::computeStretch(), Isis::MosaicSceneItem::getStretch(), Isis::StretchTool::histFromBuffer(), Isis::VisualDisplay::setPixelData(), Isis::LinearStretchType::setStretch(), Isis::StretchTool::stretchBand(), and Isis::StretchTool::stretchBuffer().

double Isis::Statistics::BestMinimum ( const double  percent = 99.5) const

This method returns the better of the absolute minimum or the Chebyshev minimum.

The better value is considered the value closest to the mean.

Parameters
percentThe probability that the minimum is within K standard deviations of the mean (Used to compute the Chebyshev minimum). Default value = 99.5.
Returns
Best of absolute and Chebyshev minimums
See Also
Statistics::Minimum Statistics::ChebyshevMinimum

Definition at line 405 of file Statistics.cpp.

Referenced by Isis::ChipViewport::computeStretch(), Isis::MosaicSceneItem::getStretch(), Isis::StretchTool::histFromBuffer(), Isis::VisualDisplay::setPixelData(), Isis::LinearStretchType::setStretch(), Isis::StretchTool::stretchBand(), and Isis::StretchTool::stretchBuffer().

double Isis::Statistics::ChebyshevMaximum ( const double  percent = 99.5) const

This method returns a maximum such that X percent of the data will fall with K standard deviations of the average (Chebyshev's Theorem).

It can be used to obtain a minimum that does not include statistical outliers.

Parameters
percentThe probability that the maximum is within K standard deviations of the mean. Default value = 99.5.
Returns
maximum value excluding statistical outliers
Exceptions
Isis::IException::Message

Definition at line 380 of file Statistics.cpp.

References _FILEINFO_.

double Isis::Statistics::ChebyshevMinimum ( const double  percent = 99.5) const

This method returns a minimum such that X percent of the data will fall with K standard deviations of the average (Chebyshev's Theorem).

It can be used to obtain a minimum that does not include statistical outliers.

Parameters
percentThe probability that the minimum is within K standard deviations of the mean. Default value = 99.5.
Returns
Minimum value (excluding statistical outliers)
Exceptions
Isis::IException::Message

Definition at line 354 of file Statistics.cpp.

References _FILEINFO_.

BigInt Isis::Statistics::HisPixels ( ) const

Returns the total number of high instrument saturation (HIS) pixels encountered.

Returns
The number of HIS pixels (data) processed

Definition at line 315 of file Statistics.cpp.

BigInt Isis::Statistics::HrsPixels ( ) const

Returns the total number of high representation saturation (HRS) pixels encountered.

Returns
The number of HRS pixels (data) processed

Definition at line 325 of file Statistics.cpp.

BigInt Isis::Statistics::LisPixels ( ) const

Returns the total number of low instrument saturation (LIS) pixels encountered.

Returns
The number of LIS pixels (data) processed

Definition at line 295 of file Statistics.cpp.

BigInt Isis::Statistics::LrsPixels ( ) const

Returns the total number of low representation saturation (LRS) pixels encountered.

Returns
The number of LRS pixels (data) processed

Definition at line 305 of file Statistics.cpp.

double Isis::Statistics::Maximum ( ) const

Returns the absolute maximum double found in all data passed through the AddData method.

If there are no valid pixels, then NULL8 is returned.

Returns
Current maximum value in data set
Exceptions
Isis::IException::MessageThe data set is blank, so the maximum is invalid.

Definition at line 228 of file Statistics.cpp.

References _FILEINFO_.

Referenced by Isis::BinaryStretchType::calculateNewStretch(), Isis::SawtoothStretchType::calculateNewStretch(), Isis::AutoReg::ComputeChipZScore(), Isis::BinaryStretchType::endEditChanged(), Isis::LinearStretchType::endEditChanged(), Isis::BinaryStretchType::endSliderMoved(), Isis::LinearStretchType::endSliderMoved(), Isis::QnetPointJigsawErrorFilter::filter(), Isis::QnetPointRegistrationErrorFilter::filter(), Isis::GaussianStretch::GaussianStretch(), Isis::ControlNet::GetMaximumResidual(), Isis::ControlNetStatistics::GetPointDoubleStats(), Isis::StatisticsTool::getStatistics(), Isis::SawtoothStretchType::offsetEditChanged(), Isis::SawtoothStretchType::offsetSliderMoved(), Isis::VisualDisplay::paintPixmap(), Isis::HistogramTool::refreshPlot(), Isis::SawtoothStretchType::SawtoothStretchType(), Isis::ScatterPlotData::ScatterPlotData(), Isis::HistogramWidget::setHistogram(), Isis::BinaryStretchType::setStretch(), Isis::BinaryStretchType::startEditChanged(), Isis::LinearStretchType::startEditChanged(), Isis::BinaryStretchType::startSliderMoved(), Isis::LinearStretchType::startSliderMoved(), Isis::Gruen::StatsLog(), Isis::StretchTool::stretchBuffer(), Isis::CameraStatistics::toPvl(), Isis::SawtoothStretchType::widthEditChanged(), and Isis::SawtoothStretchType::widthSliderMoved().

double Isis::Statistics::Minimum ( ) const

Returns the absolute minimum double found in all data passed through the AddData method.

If there are no valid pixels, then NULL8 is returned.

Returns
Current minimum value in data set.
Exceptions
Isis::IException::MessageThe data set is blank, so the minimum is invalid.

Definition at line 208 of file Statistics.cpp.

References _FILEINFO_.

Referenced by Isis::BinaryStretchType::calculateNewStretch(), Isis::SawtoothStretchType::calculateNewStretch(), Isis::AutoReg::ComputeChipZScore(), Isis::BinaryStretchType::endEditChanged(), Isis::LinearStretchType::endEditChanged(), Isis::BinaryStretchType::endSliderMoved(), Isis::LinearStretchType::endSliderMoved(), Isis::GaussianStretch::GaussianStretch(), Isis::ControlNetStatistics::GetPointDoubleStats(), Isis::StatisticsTool::getStatistics(), Isis::SawtoothStretchType::offsetEditChanged(), Isis::SawtoothStretchType::offsetSliderMoved(), Isis::VisualDisplay::paintPixmap(), Isis::HistogramTool::refreshPlot(), Isis::SawtoothStretchType::SawtoothStretchType(), Isis::ScatterPlotData::ScatterPlotData(), Isis::HistogramWidget::setHistogram(), Isis::BinaryStretchType::setStretch(), Isis::BinaryStretchType::startEditChanged(), Isis::LinearStretchType::startEditChanged(), Isis::BinaryStretchType::startSliderMoved(), Isis::LinearStretchType::startSliderMoved(), Isis::Gruen::StatsLog(), Isis::StretchTool::stretchBuffer(), Isis::CameraStatistics::toPvl(), Isis::SawtoothStretchType::widthEditChanged(), and Isis::SawtoothStretchType::widthSliderMoved().

BigInt Isis::Statistics::NullPixels ( ) const

Returns the total number of NULL pixels encountered.

Returns
The number of NULL pixels (data) processed

Definition at line 285 of file Statistics.cpp.

BigInt Isis::Statistics::OutOfRangePixels ( ) const

Returns the total number of pixels outside of the valid range encountered.

Returns
The number of Out of Range pixels (data) processed

Definition at line 335 of file Statistics.cpp.

BigInt Isis::Statistics::OverRangePixels ( ) const

Returns the total number of pixels over the valid range encountered.

Returns
The number of pixels less than the ValidMaximum() processed

Definition at line 266 of file Statistics.cpp.

void Isis::Statistics::RemoveData ( const double *  data,
const unsigned int  count 
)

Remove an array of doubles from the accumulators and counters.

Note that is invalidates the absolute minimum and maximum. They will no longer be usable.

Parameters
dataThe data to be removed from data set used for statistical calculations.
countThe number of elements in the data to be removed.
Exceptions
Isis::IException::MessageRemoveData is trying to remove data that doesn't exist.

Definition at line 88 of file Statistics.cpp.

References _FILEINFO_, Isis::IsHisPixel(), Isis::IsHrsPixel(), Isis::IsLisPixel(), Isis::IsLrsPixel(), Isis::IsNullPixel(), and Isis::IsValidPixel().

Referenced by Isis::MultivariateStatistics::RemoveData().

void Isis::Statistics::Reset ( )
double Isis::Statistics::Rms ( ) const

Computes and returns the rms.

If there are no valid pixels, then NULL8 is returned.

Returns
The rms (root mean square)
History:
2011-06-13 Ken Edmundson.

Definition at line 192 of file Statistics.cpp.

Referenced by Isis::BundleAdjust::ComputeBundleStatistics(), Isis::ControlPoint::GetLineResidualRms(), Isis::ControlPoint::GetResidualRms(), and Isis::ControlPoint::GetSampleResidualRms().

double Isis::Statistics::Sum ( ) const
inline

Returns the sum of all the data.

Returns
The sum of the data

Definition at line 176 of file Statistics.h.

References p_sum.

Referenced by Isis::MultivariateStatistics::Covariance(), and Isis::MultivariateStatistics::LinearRegression().

double Isis::Statistics::SumSquare ( ) const
inline

Returns the sum of all the squared data.

Returns
The sum of the squared data

Definition at line 185 of file Statistics.h.

References p_sumsum.

Referenced by Isis::MultivariateStatistics::LinearRegression().

BigInt Isis::Statistics::TotalPixels ( ) const

Returns the total number of pixels processed (valid and invalid).

Returns
The number of pixels (data) processed

Definition at line 244 of file Statistics.cpp.

Referenced by Isis::VisualDisplay::paintPixmap().

BigInt Isis::Statistics::UnderRangePixels ( ) const

Returns the total number of pixels under the valid range encountered.

Returns
The number of pixels less than the ValidMinimum() processed

Definition at line 276 of file Statistics.cpp.

BigInt Isis::Statistics::ValidPixels ( ) const

Returns the total number of valid pixels processed.

Only valid pixels are utilized when computing the average, standard deviation, variance, minimum and maximum.

Returns
The number of valid pixels (data) processed

Definition at line 256 of file Statistics.cpp.

Referenced by Isis::OverlapNormalization::AddOverlap(), Isis::ControlNetStatistics::GetPointDoubleStats(), Isis::StatisticsTool::getStatistics(), Isis::QHistogram::Load(), Isis::HistogramTool::refreshPlot(), Isis::StretchTool::stretchBuffer(), and Isis::StretchTool::updateHistograms().

double Isis::Statistics::Variance ( ) const

Computes and returns the variance.

If there are no valid pixels, then NULL8 is returned.

Returns
The variance
History:
2003-08-27 Jeff Anderson - Modified Variance method to compute using n*(n-1) instead of n*n.

Definition at line 176 of file Statistics.cpp.

Referenced by Isis::HistogramTool::refreshPlot().

double Isis::Statistics::ZScore ( const double  value) const

This method returns the better of the z-score of the given value.

The z-score is the number of standard deviations the value lies above or below the average.

Parameters
valueThe value to calculate the z-score of.
Returns
z-score

Definition at line 446 of file Statistics.cpp.

References _FILEINFO_.

Referenced by Isis::AutoReg::ComputeChipZScore().

Member Data Documentation

BigInt Isis::Statistics::p_hisPixels
private

Count of high instrument representation pixels processed.

Definition at line 202 of file Statistics.h.

Referenced by AddData().

BigInt Isis::Statistics::p_hrsPixels
private

Count of high instrument saturation pixels processed.

Definition at line 201 of file Statistics.h.

Referenced by AddData().

BigInt Isis::Statistics::p_lisPixels
private

Count of low representation saturation pixels processed.

Definition at line 200 of file Statistics.h.

Referenced by AddData().

BigInt Isis::Statistics::p_lrsPixels
private

Count of low instrument saturation pixels processed.

Definition at line 199 of file Statistics.h.

Referenced by AddData().

double Isis::Statistics::p_maximum
private

Maximum double value encountered.

Definition at line 193 of file Statistics.h.

Referenced by AddData().

double Isis::Statistics::p_minimum
private

Minimum double value encountered.

Definition at line 192 of file Statistics.h.

Referenced by AddData().

BigInt Isis::Statistics::p_nullPixels
private

Count of null pixels processed.

Definition at line 198 of file Statistics.h.

Referenced by AddData().

BigInt Isis::Statistics::p_overRangePixels
private

Count of pixels greater than the valid range.

Definition at line 204 of file Statistics.h.

Referenced by AddData().

bool Isis::Statistics::p_removedData
private

   Indicates the RemoveData method was called which implies

p_minimum and p_maximum are invalid.

Definition at line 205 of file Statistics.h.

double Isis::Statistics::p_sum
private

Sum accumulator.

Definition at line 187 of file Statistics.h.

Referenced by AddData(), and Sum().

double Isis::Statistics::p_sumsum
private

Sum-squared accumulator.

Definition at line 191 of file Statistics.h.

Referenced by AddData(), and SumSquare().

BigInt Isis::Statistics::p_totalPixels
private

Count of total pixels processed.

Definition at line 196 of file Statistics.h.

Referenced by AddData().

BigInt Isis::Statistics::p_underRangePixels
private

Count of pixels less than the valid range.

Definition at line 203 of file Statistics.h.

Referenced by AddData().

double Isis::Statistics::p_validMaximum
private

Maximum valid pixel value.

Definition at line 195 of file Statistics.h.

double Isis::Statistics::p_validMinimum
private

Minimum valid pixel value.

Definition at line 194 of file Statistics.h.

BigInt Isis::Statistics::p_validPixels
private

Count of valid pixels (non-special) processed.

Definition at line 197 of file Statistics.h.

Referenced by AddData().


The documentation for this class was generated from the following files: