Isis 3.0
Home
StatCumProbDistDynCalc.h
Go to the documentation of this file.
1 #ifndef StatCumProbDistDynCalc_h
2 #define StatCumProbDistDynCalc_h
3 
24 #include <QList>
25 #include <QObject>
26 #include <QVector>
27 
28 #include "XmlStackedHandler.h"
29 
30 class QDataStream;
31 class QUuid;
32 class QXmlStreamWriter;
33 
34 namespace Isis {
35  class Project;// ??? does xml stuff need project???
36  class XmlStackedHandlerReader;
37 
80  Q_OBJECT
81  // class uses the P^2 Algorithim to calculate equiprobability cell histograms from a stream of
82  // data without storing the data
83  // see "The p^2 Algorithim for Dynamic Calculations of Quantiles and Histograms Without Storing
84  // Observations"
85  public:
86  StatCumProbDistDynCalc(unsigned int nodes=20, QObject *parent = 0); //individual qunatile value to be calculated
88  QObject *parent = 0); // TODO: does xml stuff need project???
92 
93  void initialize(); // clears the member lists and initializes the rest of the member data to 0
94  void setQuantiles(unsigned int nodes); // initializes/resets the class to start new calculation
95 
96  void validate();
97  void addObs(double obs);
98 
99  double cumProb(double value); //given a value return the cumulative probility
100  double value(double cumProb); //given a cumulative probibility return a value
101  double max(); //return the largest value so far
102  double min(); //return the smallest values so far
103 
104  void save(QXmlStreamWriter &stream, const Project *project) const; // TODO: does xml stuff need project???
105 
106  QDataStream &write(QDataStream &stream) const;
107  QDataStream &read(QDataStream &stream);
108 
109  private:
116  class XmlHandler : public XmlStackedHandler {
117  public:
118  XmlHandler(StatCumProbDistDynCalc *probabilityCalc, Project *project); // TODO: does xml stuff need project???
119  ~XmlHandler();
120 
121  virtual bool startElement(const QString &namespaceURI, const QString &localName,
122  const QString &qName, const QXmlAttributes &atts);
123  virtual bool characters(const QString &ch);
124  virtual bool endElement(const QString &namespaceURI, const QString &localName,
125  const QString &qName);
126 
127  private:
128  Q_DISABLE_COPY(XmlHandler);
129 
130  StatCumProbDistDynCalc *m_xmlHandlerCumProbCalc;
131  Project *m_xmlHandlerProject; // TODO: does xml stuff need project???
132  QString m_xmlHandlerCharacters;
133  };
134 
135  QUuid *m_id;
138  unsigned int m_numberCells;
141  unsigned int m_numberQuantiles;
145  unsigned int m_numberObservations;
148  QList<double> m_quantiles;
150  QList<double> m_observationValues;
153  QList<double> m_idealNumObsBelowQuantile;
158  QList<int> m_numObsBelowQuantile;
162  };
163 
164  // operators to read/write StatCumProbDistDynCalc to/from binary data
165  QDataStream &operator<<(QDataStream &stream, const StatCumProbDistDynCalc &scpddc);
166  QDataStream &operator>>(QDataStream &stream, StatCumProbDistDynCalc &scpddc);
167 
168 } //end namespace Isis
169 
170 #endif
double max()
Returns the maximum observation so far included in the dynamic calculation.
Definition: StatCumProbDistDynCalc.cpp:166
The main project for cnetsuite.
Definition: Project.h:105
void setQuantiles(unsigned int nodes)
Definition: StatCumProbDistDynCalc.cpp:128
QDataStream & write(QDataStream &stream) const
Definition: StatCumProbDistDynCalc.cpp:619
StatCumProbDistDynCalc(unsigned int nodes=20, QObject *parent=0)
Construtor sets up the class to start recieving data.
Definition: StatCumProbDistDynCalc.cpp:50
void validate()
Definition: StatCumProbDistDynCalc.cpp:667
double value(double cumProb)
Provides the value of the variable that has the given cumulative probility (according the current est...
Definition: StatCumProbDistDynCalc.cpp:205
~StatCumProbDistDynCalc()
Destroys StatCumProbDistDynCalc object.
Definition: StatCumProbDistDynCalc.cpp:83
This class is used to approximate cumulative probibility distributions of a stream of observations wi...
Definition: StatCumProbDistDynCalc.h:79
std::istream & operator>>(std::istream &is, CSVReader &csv)
Input read operator for input stream sources.
Definition: CSVReader.cpp:463
XML Handler that parses XMLs in a stack-oriented way.
Definition: XmlStackedHandler.h:47
QDataStream & read(QDataStream &stream)
Definition: StatCumProbDistDynCalc.cpp:633
void save(QXmlStreamWriter &stream, const Project *project) const
Definition: StatCumProbDistDynCalc.cpp:514
void initialize()
Inializer, resets the class to start its dynamic calculation anew.
Definition: StatCumProbDistDynCalc.cpp:117
void addObs(double obs)
Values for the estimated quantile positions are update as observations are added. ...
Definition: StatCumProbDistDynCalc.cpp:417
double min()
Returns the maximum observation so far included in the dynamic calculation.
Definition: StatCumProbDistDynCalc.cpp:183
QDebug operator<<(QDebug debug, const Hillshade &hillshade)
Print this class out to a QDebug object.
Definition: Hillshade.cpp:308
double cumProb(double value)
Provides the cumulative probility, that is, the proportion of the distribution that is less than or e...
Definition: StatCumProbDistDynCalc.cpp:322
his enables stack-based XML parsing of XML files.
Definition: XmlStackedHandlerReader.h:26
StatCumProbDistDynCalc & operator=(const StatCumProbDistDynCalc &other)
Definition: StatCumProbDistDynCalc.cpp:90