Files
Upsilon/apps/regression/data.h
Émilie Feral e0b56e6588 [apps] add methods to the abstract model "data"
Change-Id: I24993d6ffcee9b030716c310f48260a78fe61546
2017-01-09 15:08:56 +01:00

82 lines
2.1 KiB
C++

#ifndef REGRESSION_DATA_H
#define REGRESSION_DATA_H
#include "../curve_view_window_with_cursor.h"
#include "../data.h"
namespace Regression {
class Data : public ::Data, public CurveViewWindowWithCursor {
public:
Data();
// Delete the implicit copy constructor: the object is heavy
Data(const Data&) = delete;
// Raw numeric data
float xValueAtIndex(int index) override;
float yValueAtIndex(int index) override;
void setXValueAtIndex(float value, int index) override;
void setYValueAtIndex(float value, int index) override;
void deletePairAtIndex(int index) override;
void deleteAllXValues() override;
void deleteAllYValues() override;
// Cursor
int moveCursorHorizontally(int direction) override;
// the result of moveCursorVertically means:
// 0-> the window has not changed 1->the window changed
int moveCursorVertically(int direction) override;
/* The selectedDotIndex is -1 when no dot is selected, m_numberOfPairs when
* the mean dot is selected and the dot index otherwise */
int selectedDotIndex();
void setCursorPositionAtAbscissa(float abscissa);
void setCursorPositionAtOrdinate(float ordinate);
// Window
void setDefault();
// Calculation
float xSum();
float ySum();
float xSquaredValueSum();
float ySquaredValueSum();
float xyProductSum();
float xMean();
float yMean();
float xVariance();
float yVariance();
float xStandardDeviation();
float yStandardDeviation();
float covariance();
float slope();
float yIntercept();
float yValueForXValue(float x);
float xValueForYValue(float y);
float correlationCoefficient();
float squaredCorrelationCoefficient();
constexpr static int k_maxNumberOfPairs = 500;
private:
float maxXValue();
float maxYValue();
float minXValue();
float minYValue();
void initWindowParameters();
bool computeYaxis() override;
void initCursorPosition() override;
int selectClosestDotRelativelyToCurve(int direction);
int selectNextDot(int direction);
// Raw numeric data
int m_xValues[k_maxNumberOfPairs];
float m_yValues[k_maxNumberOfPairs];
// Cursor
int m_selectedDotIndex;
};
}
#endif