Isis 3 Programmer Reference
|
Container of multivariate statistics. More...
#include <MultivariateStatistics.h>
Public Member Functions | |
MultivariateStatistics () | |
Constructs a Multivariate Statistics object with accumulators and counters set to zero. More... | |
MultivariateStatistics (const PvlObject &inStats) | |
Constructs a MulitvariateStatistics object from a PvlObject. More... | |
~MultivariateStatistics () | |
Destructs a MultivariateStatistics object. More... | |
void | Reset () |
Resets all accumulators to zero. More... | |
void | AddData (const double *x, const double *y, const unsigned int count) |
Add two arrays of doubles to the accumulators and counters. More... | |
void | AddData (double x, double y, unsigned int count=1) |
Add an x,y value to the accumulators and counters count times. More... | |
void | RemoveData (const double *x, const double *y, const unsigned int count) |
Remove an array of doubles from the accumulators and counters. More... | |
Isis::Statistics | X () const |
Returns a Stats object for all of the X data fed through the AddData method. More... | |
Isis::Statistics | Y () const |
Returns a Stats object for all of the Y data fed through the AddData method. More... | |
double | SumXY () const |
Returns the sum of x*y for all data given through the AddData method. More... | |
double | Covariance () const |
Computes and returns the covariance between the two data sets If there are no valid data (pixels) then NULL8 is returned. More... | |
double | Correlation () const |
Computes and returns the coefficient of correlation (between -1.0 and 1.0) of the two data sets. More... | |
void | LinearRegression (double &a, double &b) const |
Fits a line \[ y=A+Bx \] through the data. More... | |
BigInt | ValidPixels () const |
Returns the number of valid pixels processed. More... | |
BigInt | InvalidPixels () const |
Returns the number of invalid pixels encountered. More... | |
BigInt | TotalPixels () const |
Returns the total number of pixels processed. More... | |
PvlObject | toPvl (QString name="MultivariateStatistics") const |
Serializes a multivariate statistics object as a PvlObject. More... | |
Private Member Functions | |
void | fromPvl (const PvlObject &inStats) |
Unserializes a multivariate statistics object from a PvlObject. More... | |
Private Attributes | |
Isis::Statistics | p_x |
A Statistics object holding x data. More... | |
Isis::Statistics | p_y |
A Statistics object holding y data. More... | |
double | p_sumxy |
The sum of x and y. More... | |
BigInt | p_validPixels |
The number of valid (computed) pixels. More... | |
BigInt | p_invalidPixels |
The number of invalid (ignored) pixels. More... | |
BigInt | p_totalPixels |
The total number of pixels (invalid and valid). More... | |
Container of multivariate statistics.
This class is used to accumulate multivariate statisics on two double arrays. In particular, it is highly useful for obtaining the covariance, correlation, and linear regression analysis on the the data. It ignores input values which are Isis special pixel values. That is, if either co-aligned double value is a special pixel then both values are not used in any statistical computation.
2005-03-28 Leah Dahmer modified file to support Doxygen documentation.
2005-05-23 Jeff Anderson - Added 2GB+ file support
2012-01-03 Steven Lambright - Added AddData(double, double, unsigned int) for a significant performance improvement and to increase the consistency in the API relative to the Statistics class.
2016-07-15 Ian Humphrey - Added constructor to initialize a MultivariateStatistics object from a PvlObject. Added fromPvl() and toPvl() methods to allow for serialization/unserialization with PvlObjects. Updated unit test. References #2282.
This class needs an example.
For the below methods we will need to compute log x, loy y, sumx3, sumx4,sumx2y: void ExponentialRegression (double &a, double &b) const; void PowerRegression (double &a, double &b) const; void parabolicRegression (double &a, double &b, double &c);
Definition at line 71 of file MultivariateStatistics.h.
Isis::MultivariateStatistics::MultivariateStatistics | ( | ) |
Constructs a Multivariate Statistics object with accumulators and counters set to zero.
Definition at line 41 of file MultivariateStatistics.cpp.
References Reset().
Isis::MultivariateStatistics::MultivariateStatistics | ( | const PvlObject & | inStats | ) |
Isis::MultivariateStatistics::~MultivariateStatistics | ( | ) |
Destructs a MultivariateStatistics object.
Definition at line 70 of file MultivariateStatistics.cpp.
void Isis::MultivariateStatistics::AddData | ( | const double * | x, |
const double * | y, | ||
const unsigned int | count | ||
) |
Add two arrays of doubles to the accumulators and counters.
This method can be invoked multiple times, for example, once for each line in a cube, before obtaining statistics.
x | Array of doubles to add. |
y | Array of doubles to add. |
count | Number of doubles to process. |
Definition at line 82 of file MultivariateStatistics.cpp.
References Isis::Statistics::AddData(), Isis::IsValidPixel(), p_invalidPixels, p_sumxy, p_totalPixels, p_validPixels, p_x, and p_y.
Referenced by Isis::MaximumCorrelation::MatchAlgorithm(), and Isis::ZeroBufferFit::poly_fit().
void Isis::MultivariateStatistics::AddData | ( | double | x, |
double | y, | ||
unsigned int | count = 1 |
||
) |
Add an x,y value to the accumulators and counters count times.
This method can be invoked multiple times before obtaining statistics.
x | x value to add |
y | y value to add |
count | Number of times to add this x,y value |
Definition at line 110 of file MultivariateStatistics.cpp.
References Isis::Statistics::AddData(), Isis::IsValidPixel(), p_invalidPixels, p_sumxy, p_totalPixels, p_validPixels, p_x, and p_y.
double Isis::MultivariateStatistics::Correlation | ( | ) | const |
Computes and returns the coefficient of correlation (between -1.0 and 1.0) of the two data sets.
This can be used as a goodness-of-fit measurement. The close the correlation is two -1.0 or 1.0 the more likely the data sets are related (and therefore the regression equation is valid).
Definition at line 187 of file MultivariateStatistics.cpp.
References Covariance(), p_validPixels, p_x, p_y, and Isis::Statistics::StandardDeviation().
Referenced by Isis::MaximumCorrelation::MatchAlgorithm(), and toPvl().
double Isis::MultivariateStatistics::Covariance | ( | ) | const |
Computes and returns the covariance between the two data sets If there are no valid data (pixels) then NULL8 is returned.
Definition at line 169 of file MultivariateStatistics.cpp.
References Isis::Statistics::Average(), p_sumxy, p_validPixels, p_x, p_y, and Isis::Statistics::Sum().
Referenced by Correlation(), and toPvl().
|
private |
Unserializes a multivariate statistics object from a PvlObject.
const | PvlObject & - Input multivariate statistics |
Definition at line 288 of file MultivariateStatistics.cpp.
References Isis::PvlObject::findGroup(), p_invalidPixels, p_sumxy, p_totalPixels, p_validPixels, p_x, and p_y.
Referenced by MultivariateStatistics().
BigInt Isis::MultivariateStatistics::InvalidPixels | ( | ) | const |
Returns the number of invalid pixels encountered.
Definition at line 227 of file MultivariateStatistics.cpp.
References p_invalidPixels.
Referenced by toPvl().
void Isis::MultivariateStatistics::LinearRegression | ( | double & | a, |
double & | b | ||
) | const |
Fits a line
\[ y=A+Bx \]
through the data.
a | The additive constant A. |
b | The additive constant B. |
Definition at line 238 of file MultivariateStatistics.cpp.
References _FILEINFO_, p_sumxy, p_validPixels, p_x, p_y, Isis::IException::Programmer, Isis::Statistics::Sum(), and Isis::Statistics::SumSquare().
Referenced by Isis::ZeroBufferFit::poly_fit(), and toPvl().
void Isis::MultivariateStatistics::RemoveData | ( | const double * | x, |
const double * | y, | ||
const unsigned int | count | ||
) |
Remove an array of doubles from the accumulators and counters.
x | Pointer to an array of doubles to remove. |
y | Array of doubles to add. |
count | Number of doubles to process. |
Definition at line 140 of file MultivariateStatistics.cpp.
References _FILEINFO_, Isis::IsValidPixel(), p_invalidPixels, p_sumxy, p_totalPixels, p_validPixels, p_x, p_y, Isis::IException::Programmer, and Isis::Statistics::RemoveData().
void Isis::MultivariateStatistics::Reset | ( | ) |
Resets all accumulators to zero.
Definition at line 58 of file MultivariateStatistics.cpp.
References p_invalidPixels, p_sumxy, p_totalPixels, p_validPixels, p_x, p_y, and Isis::Statistics::Reset().
Referenced by MultivariateStatistics().
double Isis::MultivariateStatistics::SumXY | ( | ) | const |
Returns the sum of x*y for all data given through the AddData method.
Definition at line 258 of file MultivariateStatistics.cpp.
References p_sumxy.
Referenced by toPvl().
PvlObject Isis::MultivariateStatistics::toPvl | ( | QString | name = "MultivariateStatistics" | ) | const |
Serializes a multivariate statistics object as a PvlObject.
QString | (Default value is "MultivariateStatistics") - Name of the PvlObject |
Definition at line 309 of file MultivariateStatistics.cpp.
References Isis::PvlObject::addGroup(), Correlation(), Covariance(), InvalidPixels(), LinearRegression(), SumXY(), Isis::Statistics::toPvl(), Isis::toString(), TotalPixels(), ValidPixels(), X(), and Y().
BigInt Isis::MultivariateStatistics::TotalPixels | ( | ) | const |
Returns the total number of pixels processed.
Definition at line 205 of file MultivariateStatistics.cpp.
References p_totalPixels.
Referenced by toPvl().
BigInt Isis::MultivariateStatistics::ValidPixels | ( | ) | const |
Returns the number of valid pixels processed.
Only valid pixels are utilized when computing the average, standard deviation, variance, minimum, and maximum.
Definition at line 217 of file MultivariateStatistics.cpp.
References p_validPixels.
Referenced by Isis::Equalization::calculateOverlapStatistics(), Isis::Equalization::fromPvl(), Isis::OverlapStatistics::IsValid(), Isis::MaximumCorrelation::MatchAlgorithm(), and toPvl().
Isis::Statistics Isis::MultivariateStatistics::X | ( | ) | const |
Returns a Stats object for all of the X data fed through the AddData method.
Definition at line 268 of file MultivariateStatistics.cpp.
References p_x.
Referenced by Isis::Equalization::calculateOverlapStatistics(), Isis::Equalization::fromPvl(), and toPvl().
Isis::Statistics Isis::MultivariateStatistics::Y | ( | ) | const |
Returns a Stats object for all of the Y data fed through the AddData method.
Definition at line 278 of file MultivariateStatistics.cpp.
References p_y.
Referenced by Isis::Equalization::calculateOverlapStatistics(), Isis::Equalization::fromPvl(), and toPvl().
|
private |
The number of invalid (ignored) pixels.
Definition at line 118 of file MultivariateStatistics.h.
Referenced by AddData(), fromPvl(), InvalidPixels(), RemoveData(), and Reset().
|
private |
The sum of x and y.
Definition at line 108 of file MultivariateStatistics.h.
Referenced by AddData(), Covariance(), fromPvl(), LinearRegression(), RemoveData(), Reset(), and SumXY().
|
private |
The total number of pixels (invalid and valid).
Definition at line 123 of file MultivariateStatistics.h.
Referenced by AddData(), fromPvl(), RemoveData(), Reset(), and TotalPixels().
|
private |
The number of valid (computed) pixels.
Definition at line 113 of file MultivariateStatistics.h.
Referenced by AddData(), Correlation(), Covariance(), fromPvl(), LinearRegression(), RemoveData(), Reset(), and ValidPixels().
|
private |
A Statistics object holding x data.
Definition at line 103 of file MultivariateStatistics.h.
Referenced by AddData(), Correlation(), Covariance(), fromPvl(), LinearRegression(), RemoveData(), Reset(), and X().
|
private |
A Statistics object holding y data.
Definition at line 105 of file MultivariateStatistics.h.
Referenced by AddData(), Correlation(), Covariance(), fromPvl(), LinearRegression(), RemoveData(), Reset(), and Y().