summaryrefslogtreecommitdiffstats
path: root/stats/statsview.h
diff options
context:
space:
mode:
authorGravatar Robert C. Helling <helling@atdotde.de>2021-01-12 19:39:25 +0100
committerGravatar Robert C. Helling <helling@atdotde.de>2021-01-14 20:51:23 +0100
commitd6712bc5ac1af3bd1bc42c62d66a0df7be56e68b (patch)
treef8a44afcabe12f30561edc51bd700060b7bc993c /stats/statsview.h
parent5775bd7b27f0c71a78cfe526b971c3f1652b4add (diff)
downloadsubsurface-d6712bc5ac1af3bd1bc42c62d66a0df7be56e68b.tar.gz
Plot proper confidence regions
I was coninced that that rather than doing an order of magnitude estimate of the confidence region it's better to have the correct concave shapes that indicate the 95% confidence level for the regression line. It also turned out that the previous expression was missing a factor of 1/sqrt(n). Signed-off-by: Robert C. Helling <helling@atdotde.de>
Diffstat (limited to 'stats/statsview.h')
-rw-r--r--stats/statsview.h14
1 files changed, 10 insertions, 4 deletions
diff --git a/stats/statsview.h b/stats/statsview.h
index 198ded14f..b2c973856 100644
--- a/stats/statsview.h
+++ b/stats/statsview.h
@@ -31,6 +31,13 @@ class QSGTexture;
enum class ChartSubType : int;
enum class StatsOperation : int;
+struct regression_data {
+ double a,b;
+ double res2, r2, sx2, xavg;
+ int n;
+};
+
+
class StatsView : public QQuickItem {
Q_OBJECT
public:
@@ -120,10 +127,9 @@ private:
struct RegressionLine {
std::unique_ptr<QGraphicsPolygonItem> item;
StatsAxis *xAxis, *yAxis;
- double a, b; // y = ax + b
- double width;
+ const struct regression_data reg;
void updatePosition();
- RegressionLine(double a, double b, double width, QBrush brush, QGraphicsScene *scene, StatsAxis *xAxis, StatsAxis *yAxis);
+ RegressionLine(const struct regression_data reg, QBrush brush, QGraphicsScene *scene, StatsAxis *xAxis, StatsAxis *yAxis);
};
// A line marking median or mean in histograms
@@ -136,7 +142,7 @@ private:
HistogramMarker(double val, bool horizontal, QPen pen, QGraphicsScene *scene, StatsAxis *xAxis, StatsAxis *yAxis);
};
- void addLinearRegression(double a, double b, double res2, double r2, double minX, double maxX, double minY, double maxY, StatsAxis *xAxis, StatsAxis *yAxis);
+ void addLinearRegression(const struct regression_data reg, StatsAxis *xAxis, StatsAxis *yAxis);
void addHistogramMarker(double pos, const QPen &pen, bool isHorizontal, StatsAxis *xAxis, StatsAxis *yAxis);
StatsState state;