JKQTPlotter trunk/v5.0.0
an extensive Qt5+Qt6 Plotter framework (including a feature-richt plotter widget, a speed-optimized, but limited variant and a LaTeX equation renderer!), written fully in C/C++ and without external dependencies
Loading...
Searching...
No Matches
jkqtpstatisticsadaptors.h
1/*
2 Copyright (c) 2008-2024 Jan W. Krieger (<jan@jkrieger.de>)
3
4
5
6 This software is free software: you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License (LGPL) as published by
8 the Free Software Foundation, either version 2.1 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU Lesser General Public License (LGPL) for more details.
15
16 You should have received a copy of the GNU Lesser General Public License (LGPL)
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#ifndef JKQTPGRAPHSSTATISTICSADAPTORS_H_INCLUDED
21#define JKQTPGRAPHSSTATISTICSADAPTORS_H_INCLUDED
22
23
24
25#include "jkqtplotter/jkqtplotter_imexport.h"
26#include "jkqtmath/jkqtpstatisticstools.h"
27#include "jkqtcommon/jkqtpdebuggingtools.h"
28#include "jkqtplotter/jkqtpgraphsbase.h"
29#include "jkqtplotter/jkqtpgraphsbaseerrors.h"
30#include "jkqtplotter/graphs/jkqtpboxplot.h"
31#include "jkqtplotter/graphs/jkqtpscatter.h"
32#include "jkqtplotter/graphs/jkqtpsinglecolumnsymbols.h"
33#include "jkqtplotter/graphs/jkqtpbarchart.h"
34#include "jkqtplotter/graphs/jkqtpevaluatedfunction.h"
35#include "jkqtplotter/graphs/jkqtpimage.h"
36#include "jkqtplotter/graphs/jkqtpcontour.h"
37#include "jkqtplotter/graphs/jkqtpimpulses.h"
38#include "jkqtplotter/graphs/jkqtpfilledcurve.h"
39#include "jkqtplotter/graphs/jkqtpviolinplot.h"
40
41/*! \brief add a JKQTPBoxplotHorizontalElement to the given plotter, where the boxplot values are calculated from the data range \a first ... \a last
42 \ingroup jkqtptools_math_statistics_adaptors
43
44 \tparam InputIt standard iterator type of \a first and \a last.
45 \param plotter the plotter to which to add the resulting graph
46 \param first iterator pointing to the first item in the dataset to use \f$ X_1 \f$
47 \param last iterator pointing behind the last item in the dataset to use \f$ X_N \f$
48 \param boxposY y-coordinate of the boxplot
49 \param quantile1Spec specifies which quantile to calculate for \a qantile1 (range: 0..1)
50 \param quantile2Spec specifies which quantile to calculate for \a qantile2 (range: 0..1)
51 \param minimumQuantile specifies a quantile for the return value minimum (default is 0 for the real minimum, but you could e.g. use 0.05 for the 5% quantile!)
52 \param maximumQuantile specifies a quantile for the return value maximum (default is 1 for the real maximum, but you could e.g. use 0.95 for the 95% quantile!)
53 \param[out] statOutput optionally returns the internally calculated statistics as a JKQTPStat5NumberStatistics
54 \return a boxplot element with its values initialized from the given data range
55
56 Example:
57 \code
58 jkqtpstatAddHBoxplot(plot1->getPlotter(), datastore1->begin(randomdatacol1), datastore1->end(randomdatacol1), -0.3);
59 \endcode
60
61 \image html datastore_statistics_boxplots_simple.png
62
63
64 \see \ref JKQTPlotterBasicJKQTPDatastoreStatistics, jkqtpstat5NumberStatistics()
65*/
66template <class InputIt>
67inline JKQTPBoxplotHorizontalElement* jkqtpstatAddHBoxplot(JKQTBasePlotter* plotter, InputIt first, InputIt last, double boxposY, double quantile1Spec=0.25, double quantile2Spec=0.75, double minimumQuantile=0, double maximumQuantile=1.0, JKQTPStat5NumberStatistics* statOutput=nullptr) {
68 JKQTPStat5NumberStatistics stat=jkqtpstat5NumberStatistics(first, last, quantile1Spec, quantile2Spec, minimumQuantile, maximumQuantile);
69 if (statOutput) *statOutput=stat;
71 res->setMin(stat.minimum);
72 res->setMax(stat.maximum);
73 res->setMedian(stat.median);
74 res->setMean(jkqtpstatAverage(first, last));
75 res->setPercentile25(stat.quantile1);
76 res->setPercentile75(stat.quantile2);
78 res->setDrawMean(true);
79 res->setDrawNotch(true);
80 res->setDrawMedian(true);
81 res->setDrawMinMax(true);
82 res->setDrawBox(true);
83 res->setPos(boxposY);
84 plotter->addGraph(res);
85 return res;
86}
87
88
89/*! \brief add a JKQTPBoxplotVerticalElement to the given plotter, where the boxplot values are calculated from the data range \a first ... \a last
90 \ingroup jkqtptools_math_statistics_adaptors
91
92 \tparam InputIt standard iterator type of \a first and \a last.
93 \param plotter the plotter to which to add the resulting graph
94 \param first iterator pointing to the first item in the dataset to use \f$ X_1 \f$
95 \param last iterator pointing behind the last item in the dataset to use \f$ X_N \f$
96 \param boxposX x-coordinate of the boxplot
97 \param quantile1Spec specifies which quantile to calculate for \a qantile1 (range: 0..1)
98 \param quantile2Spec specifies which quantile to calculate for \a qantile2 (range: 0..1)
99 \param minimumQuantile specifies a quantile for the return value minimum (default is 0 for the real minimum, but you could e.g. use 0.05 for the 5% quantile!)
100 \param maximumQuantile specifies a quantile for the return value maximum (default is 1 for the real maximum, but you could e.g. use 0.95 for the 95% quantile!)
101 \param[out] statOutput optionally returns the internally calculated statistics as a JKQTPStat5NumberStatistics
102 \return a boxplot element with its values initialized from the given data range
103
104 Example:
105 \code
106 jkqtpstatAddVBoxplot(plot1->getPlotter(), datastore1->begin(randomdatacol1), datastore1->end(randomdatacol1), -0.3);
107 \endcode
108
109 \see \ref JKQTPlotterBasicJKQTPDatastoreStatistics, jkqtpstat5NumberStatistics()
110*/
111template <class InputIt>
112inline JKQTPBoxplotVerticalElement* jkqtpstatAddVBoxplot(JKQTBasePlotter* plotter, InputIt first, InputIt last, double boxposX, double quantile1Spec=0.25, double quantile2Spec=0.75, double minimumQuantile=0, double maximumQuantile=1.0, JKQTPStat5NumberStatistics* statOutput=nullptr) {
113 JKQTPStat5NumberStatistics stat=jkqtpstat5NumberStatistics(first, last, quantile1Spec, quantile2Spec, minimumQuantile, maximumQuantile);
114 if (statOutput) *statOutput=stat;
116 res->setMin(stat.minimum);
117 res->setMax(stat.maximum);
118 res->setMedian(stat.median);
119 res->setMean(jkqtpstatAverage(first, last));
120 res->setPercentile25(stat.quantile1);
121 res->setPercentile75(stat.quantile2);
123 res->setDrawMean(true);
124 res->setDrawNotch(true);
125 res->setDrawMedian(true);
126 res->setDrawMinMax(true);
127 res->setDrawBox(true);
128 res->setPos(boxposX);
129 plotter->addGraph(res);
130 return res;
131}
132
133
134
135/*! \brief add a JKQTPBoxplotHorizontalElement and a JKQTPSingleColumnSymbolsGraph for outliers to the given plotter, where the boxplot values are calculated from the data range \a first ... \a last
136 \ingroup jkqtptools_math_statistics_adaptors
137
138 \tparam InputIt standard iterator type of \a first and \a last.
139 \param plotter the plotter to which to add the resulting graph
140 \param first iterator pointing to the first item in the dataset to use \f$ X_1 \f$
141 \param last iterator pointing behind the last item in the dataset to use \f$ X_N \f$
142 \param boxposY y-coordinate of the outliers (and the boxplot)
143 \param quantile1Spec specifies which quantile to calculate for \a qantile1 (range: 0..1)
144 \param quantile2Spec specifies which quantile to calculate for \a qantile2 (range: 0..1)
145 \param minimumQuantile specifies a quantile for the return value minimum (default is 0 for the real minimum, but you could e.g. use 0.05 for the 5% quantile!)
146 \param maximumQuantile specifies a quantile for the return value maximum (default is 1 for the real maximum, but you could e.g. use 0.95 for the 95% quantile!)
147 \param outliercolumnBaseName this string is used in building the column names for the outlier columns
148 \param[out] statOutput optionally returns the internally calculated statistics as a JKQTPStat5NumberStatistics
149 \return a boxplot element with its values initialized from the given data range
150
151 Example:
152 \code
153 jkqtpstatAddHBoxplotAndOutliers(plot1->getPlotter(), datastore1->begin(randomdatacol1), datastore1->end(randomdatacol1), -0.3);
154 jkqtpstatAddHBoxplotAndOutliers(plot1->getPlotter(), datastore1->begin(randomdatacol1), datastore1->end(randomdatacol1), -0.3,
155 0.25, 0.75, // 1. and 3. Quartile for the boxplot box
156 0.05, 0.95 // Quantiles for the boxplot box whiskers' ends
157 \endcode
158
159 \image html datastore_statistics_boxplots_outliers.png
160
161 \see \ref JKQTPlotterBasicJKQTPDatastoreStatistics, jkqtpstat5NumberStatistics()
162*/
163template <class InputIt>
164inline std::pair<JKQTPBoxplotHorizontalElement*,JKQTPSingleColumnSymbolsGraph*> jkqtpstatAddHBoxplotAndOutliers(JKQTBasePlotter* plotter, InputIt first, InputIt last, double boxposY, double quantile1Spec=0.25, double quantile2Spec=0.75, double minimumQuantile=0.03, double maximumQuantile=0.97, const QString& outliercolumnBaseName=QString("boxplot"), JKQTPStat5NumberStatistics* statOutput=nullptr) {
165 JKQTPStat5NumberStatistics stat=jkqtpstat5NumberStatistics(first, last, quantile1Spec, quantile2Spec, minimumQuantile, maximumQuantile);
166 if (statOutput) *statOutput=stat;
168 resB->setMin(stat.minimum);
169 resB->setMax(stat.maximum);
170 resB->setMedian(stat.median);
171 resB->setMean(jkqtpstatAverage(first, last));
172 resB->setPercentile25(stat.quantile1);
173 resB->setPercentile75(stat.quantile2);
175 resB->setDrawMean(true);
176 resB->setDrawNotch(true);
177 resB->setDrawMedian(true);
178 resB->setDrawMinMax(true);
179 resB->setDrawBox(true);
180 resB->setPos(boxposY);
182 resO->setDataColumn(plotter->getDatastore()->addCopiedColumn(stat.outliers, outliercolumnBaseName));
183 resO->setPosition(boxposY);
186 resO->setColor(resB->getKeyLabelColor());
187 resO->setTitle("");
188
189 plotter->addGraph(resB);
190 plotter->addGraph(resO);
191 return std::pair<JKQTPBoxplotHorizontalElement*,JKQTPSingleColumnSymbolsGraph*>(resB, resO);
192}
193
194
195
196/*! \brief add a JKQTPBoxplotVerticalElement and a JKQTPSingleColumnSymbolsGraph for outliers to the given plotter, where the boxplot values are calculated from the data range \a first ... \a last
197 \ingroup jkqtptools_math_statistics_adaptors
198
199
200 \tparam InputIt standard iterator type of \a first and \a last.
201 \param plotter the plotter to which to add the resulting graph
202 \param first iterator pointing to the first item in the dataset to use \f$ X_1 \f$
203 \param last iterator pointing behind the last item in the dataset to use \f$ X_N \f$
204 \param boxposX x-coordinate of the outliers (and the boxplot)
205 \param quantile1Spec specifies which quantile to calculate for \a qantile1 (range: 0..1)
206 \param quantile2Spec specifies which quantile to calculate for \a qantile2 (range: 0..1)
207 \param minimumQuantile specifies a quantile for the return value minimum (default is 0.03, i.e. the 3% quantile!)
208 \param maximumQuantile specifies a quantile for the return value maximum (default is 0.97, i.e. the 97% quantile!)
209 \param outliercolumnBaseName this string is used in building the column names for the outlier columns
210 \param[out] statOutput optionally returns the internally calculated statistics as a JKQTPStat5NumberStatistics
211 \return a boxplot element with its values initialized from the given data range
212
213 Example:
214 \code
215 jkqtpstatAddVBoxplotAndOutliers(plot1->getPlotter(), datastore1->begin(randomdatacol1), datastore1->end(randomdatacol1), -0.3);
216 jkqtpstatAddVBoxplotAndOutliers(plot1->getPlotter(), datastore1->begin(randomdatacol1), datastore1->end(randomdatacol1), -0.3,
217 0.25, 0.75, // 1. and 3. Quartile for the boxplot box
218 0.05, 0.95 // Quantiles for the boxplot box whiskers' ends
219 \endcode
220
221 \see \ref JKQTPlotterBasicJKQTPDatastoreStatistics, jkqtpstat5NumberStatistics()
222*/
223template <class InputIt>
224inline std::pair<JKQTPBoxplotVerticalElement*,JKQTPSingleColumnSymbolsGraph*> jkqtpstatAddVBoxplotAndOutliers(JKQTBasePlotter* plotter, InputIt first, InputIt last, double boxposX, double quantile1Spec=0.25, double quantile2Spec=0.75, double minimumQuantile=0.03, double maximumQuantile=0.97, const QString& outliercolumnBaseName=QString("boxplot"), JKQTPStat5NumberStatistics* statOutput=nullptr) {
225 JKQTPStat5NumberStatistics stat=jkqtpstat5NumberStatistics(first, last, quantile1Spec, quantile2Spec, minimumQuantile, maximumQuantile);
226 if (statOutput) *statOutput=stat;
228 resB->setMin(stat.minimum);
229 resB->setMax(stat.maximum);
230 resB->setMedian(stat.median);
231 resB->setMean(jkqtpstatAverage(first, last));
232 resB->setPercentile25(stat.quantile1);
233 resB->setPercentile75(stat.quantile2);
235 resB->setDrawMean(true);
236 resB->setDrawNotch(true);
237 resB->setDrawMedian(true);
238 resB->setDrawMinMax(true);
239 resB->setDrawBox(true);
240 resB->setPos(boxposX);
242 resO->setDataColumn(plotter->getDatastore()->addCopiedColumn(stat.outliers, outliercolumnBaseName));
243 resO->setPosition(boxposX);
246 resO->setColor(resB->getKeyLabelColor());
247
248
249 plotter->addGraph(resB);
250 plotter->addGraph(resO);
251 return std::pair<JKQTPBoxplotVerticalElement*,JKQTPSingleColumnSymbolsGraph*>(resB, resO);
252}
253
254
255
256
257
258
259
260
261/*! \brief add a JKQTPViolinplotHorizontalElement to the given plotter, where the Violinplot values are calculated from the data range \a first ... \a last , uses a kernel density estimate as density distribution estimate
262 \ingroup jkqtptools_math_statistics_adaptors
263
264 \tparam InputIt standard iterator type of \a first and \a last.
265 \param plotter the plotter to which to add the resulting graph
266 \param first iterator pointing to the first item in the dataset to use \f$ X_1 \f$
267 \param last iterator pointing behind the last item in the dataset to use \f$ X_N \f$
268 \param violinposY y-coordinate of the Violinplot
269 \param kernel the kernel function to use (e.g. jkqtpstatKernel1DGaussian() )
270 \param bandwidth bandwidth used for the KDE, if <0 then \c jkqtpstatEstimateKDEBandwidth(first,last) is called
271 \param distBasename name basing for added columns
272 \param violinDistSamples number of samples of the distribution (between min and max)
273 \return a Violinplot element with its values initialized from the given data range
274
275 Example:
276 \code
277 jkqtpstatAddHViolinplotKDE(plot->getPlotter(), datastore1->begin(randomdatacol1), datastore1->end(randomdatacol1), -20);
278 \endcode
279
280 \image html JKQTPGraphViolinplot_ViolinHBoth.png
281
282
283 \see \ref JKQTPlotterViolinplotGraphs, JKQTPViolinplotHorizontalElement, jkqtpstatKDE1DAutoranged()
284*/
285template <class InputIt>
286inline JKQTPViolinplotHorizontalElement* jkqtpstatAddHViolinplotKDE(JKQTBasePlotter* plotter, InputIt first, InputIt last, double violinposY, const std::function<double(double)>& kernel=std::function<double(double)>(&jkqtpstatKernel1DGaussian), double bandwidth=-1, const QString& distBasename=QString("violin plot distribution"), int violinDistSamples=100) {
287 if (bandwidth<=0) bandwidth=jkqtpstatEstimateKDEBandwidth(first,last);
289 size_t cViol1Cat=plotter->getDatastore()->addColumn(distBasename+", category");
290 size_t cViol1Freq=plotter->getDatastore()->addColumn(distBasename+", KDE");
291 jkqtpstatKDE1DAutoranged(first, last, plotter->getDatastore()->backInserter(cViol1Cat), plotter->getDatastore()->backInserter(cViol1Freq),
292 violinDistSamples, kernel, bandwidth);
294 res->setMin(stat.minimum);
295 res->setMax(stat.maximum);
296 res->setMedian(stat.median);
297 res->setMean(jkqtpstatAverage(first, last));
298 res->setDrawMean(true);
299 res->setDrawMedian(true);
300 res->setDrawMinMax(true);
301 res->setPos(violinposY);
302 res->setViolinPositionColumn(cViol1Cat);
303 res->setViolinFrequencyColumn(cViol1Freq);
304 plotter->addGraph(res);
305 return res;
306}
307
308
309
310
311/*! \brief add a JKQTPViolinplotHorizontalElement to the given plotter, where the Violinplot values are calculated from the data range \a first ... \a last , uses a histogram as density distribution estimate
312 \ingroup jkqtptools_math_statistics_adaptors
313
314 \tparam InputIt standard iterator type of \a first and \a last.
315 \param plotter the plotter to which to add the resulting graph
316 \param first iterator pointing to the first item in the dataset to use \f$ X_1 \f$
317 \param last iterator pointing behind the last item in the dataset to use \f$ X_N \f$
318 \param violinposY y-coordinate of the Violinplot
319 \param distBasename name basing for added columns
320 \param violinDistSamples number of bin of the distribution (between min and max)
321 \return a Violinplot element with its values initialized from the given data range
322
323 Example:
324 \code
325 jkqtpstatAddHViolinplotHistogram(plot->getPlotter(), datastore1->begin(randomdatacol1), datastore1->end(randomdatacol1), -10);
326 \endcode
327
328 \image html jkqtpstatAddHViolinplotHistogram.png
329
330
331 \see \ref JKQTPlotterViolinplotGraphs, JKQTPViolinplotHorizontalElement, jkqtpstatHistogram1DAutoranged()
332*/
333template <class InputIt>
334inline JKQTPViolinplotHorizontalElement* jkqtpstatAddHViolinplotHistogram(JKQTBasePlotter* plotter, InputIt first, InputIt last, double violinposY, const QString& distBasename=QString("violin plot distribution"), int violinDistSamples=21) {
336 size_t cViol1Cat=plotter->getDatastore()->addColumn(distBasename+", category");
337 size_t cViol1Freq=plotter->getDatastore()->addColumn(distBasename+", histogram");
338 jkqtpstatHistogram1DAutoranged(first, last, plotter->getDatastore()->backInserter(cViol1Cat), plotter->getDatastore()->backInserter(cViol1Freq),
339 violinDistSamples);
341 res->setMin(stat.minimum);
342 res->setMax(stat.maximum);
343 res->setMedian(stat.median);
344 res->setMean(jkqtpstatAverage(first, last));
345 res->setDrawMean(true);
346 res->setDrawMedian(true);
347 res->setDrawMinMax(true);
348 res->setPos(violinposY);
349 res->setViolinPositionColumn(cViol1Cat);
350 res->setViolinFrequencyColumn(cViol1Freq);
352 plotter->addGraph(res);
353 return res;
354}
355
356
357
358
359/*! \brief add a JKQTPViolinplotVerticalElement to the given plotter, where the Violinplot values are calculated from the data range \a first ... \a last , uses a kernel density estimate as density distribution estimate
360 \ingroup jkqtptools_math_statistics_adaptors
361
362 \tparam InputIt standard iterator type of \a first and \a last.
363 \param plotter the plotter to which to add the resulting graph
364 \param first iterator pointing to the first item in the dataset to use \f$ X_1 \f$
365 \param last iterator pointing behind the last item in the dataset to use \f$ X_N \f$
366 \param violinposY y-coordinate of the Violinplot
367 \param kernel the kernel function to use (e.g. jkqtpstatKernel1DGaussian() )
368 \param bandwidth bandwidth used for the KDE, if <0 then \c jkqtpstatEstimateKDEBandwidth(first,last) is called
369 \param distBasename name basing for added columns
370 \param violinDistSamples number of samples of the distribution (between min and max)
371 \return a Violinplot element with its values initialized from the given data range
372
373 Example:
374 \code
375 jkqtpstatAddVViolinplotKDE(plot->getPlotter(), datastore1->begin(randomdatacol1), datastore1->end(randomdatacol1), -20);
376 \endcode
377
378 \image html jkqtpstatAddVViolinplotKDE.png
379
380
381 \see \ref JKQTPlotterViolinplotGraphs, JKQTPViolinplotVerticalElement, jkqtpstatKDE1DAutoranged()
382*/
383template <class InputIt>
384inline JKQTPViolinplotVerticalElement* jkqtpstatAddVViolinplotKDE(JKQTBasePlotter* plotter, InputIt first, InputIt last, double violinposY, const std::function<double(double)>& kernel=std::function<double(double)>(&jkqtpstatKernel1DGaussian), double bandwidth=-1, const QString& distBasename=QString("violin plot distribution"), int violinDistSamples=100) {
385 if (bandwidth<=0) bandwidth=jkqtpstatEstimateKDEBandwidth(first,last);
387 size_t cViol1Cat=plotter->getDatastore()->addColumn(distBasename+", category");
388 size_t cViol1Freq=plotter->getDatastore()->addColumn(distBasename+", KDE");
389 jkqtpstatKDE1DAutoranged(first, last, plotter->getDatastore()->backInserter(cViol1Cat), plotter->getDatastore()->backInserter(cViol1Freq),
390 violinDistSamples, kernel, bandwidth);
392 res->setMin(stat.minimum);
393 res->setMax(stat.maximum);
394 res->setMedian(stat.median);
395 res->setMean(jkqtpstatAverage(first, last));
396 res->setDrawMean(true);
397 res->setDrawMedian(true);
398 res->setDrawMinMax(true);
399 res->setPos(violinposY);
400 res->setViolinPositionColumn(cViol1Cat);
401 res->setViolinFrequencyColumn(cViol1Freq);
402 plotter->addGraph(res);
403 return res;
404}
405
406
407
408
409/*! \brief add a JKQTPViolinplotVerticalElement to the given plotter, where the Violinplot values are calculated from the data range \a first ... \a last , uses a histogram as density distribution estimate
410 \ingroup jkqtptools_math_statistics_adaptors
411
412 \tparam InputIt standard iterator type of \a first and \a last.
413 \param plotter the plotter to which to add the resulting graph
414 \param first iterator pointing to the first item in the dataset to use \f$ X_1 \f$
415 \param last iterator pointing behind the last item in the dataset to use \f$ X_N \f$
416 \param violinposY y-coordinate of the Violinplot
417 \param distBasename name basing for added columns
418 \param violinDistSamples number of bin of the distribution (between min and max)
419 \return a Violinplot element with its values initialized from the given data range
420
421 Example:
422 \code
423 jkqtpstatAddVViolinplotHistogram(plot->getPlotter(), datastore1->begin(randomdatacol1), datastore1->end(randomdatacol1), -10);
424 \endcode
425
426 \image html jkqtpstatAddVViolinplotHistogram.png
427
428
429 \see \ref JKQTPlotterViolinplotGraphs, JKQTPViolinplotVerticalElement, jkqtpstatHistogram1DAutoranged()
430*/
431template <class InputIt>
432inline JKQTPViolinplotVerticalElement* jkqtpstatAddVViolinplotHistogram(JKQTBasePlotter* plotter, InputIt first, InputIt last, double violinposY, const QString& distBasename=QString("violin plot distribution"), int violinDistSamples=21) {
434 size_t cViol1Cat=plotter->getDatastore()->addColumn(distBasename+", category");
435 size_t cViol1Freq=plotter->getDatastore()->addColumn(distBasename+", histogram");
436 jkqtpstatHistogram1DAutoranged(first, last, plotter->getDatastore()->backInserter(cViol1Cat), plotter->getDatastore()->backInserter(cViol1Freq),
437 violinDistSamples);
439 res->setMin(stat.minimum);
440 res->setMax(stat.maximum);
441 res->setMedian(stat.median);
442 res->setMean(jkqtpstatAverage(first, last));
443 res->setDrawMean(true);
444 res->setDrawMedian(true);
445 res->setDrawMinMax(true);
446 res->setPos(violinposY);
447 res->setViolinPositionColumn(cViol1Cat);
448 res->setViolinFrequencyColumn(cViol1Freq);
450 plotter->addGraph(res);
451 return res;
452}
453
454
455
456
457
458
459
460
461
462
463/*! \brief add a JKQTPViolinplotHorizontalElement and an outliers graph to the given plotter, where the Violinplot values are calculated from the data range \a first ... \a last , uses a kernel density estimate as density distribution estimate
464 \ingroup jkqtptools_math_statistics_adaptors
465
466 \tparam InputIt standard iterator type of \a first and \a last.
467 \param plotter the plotter to which to add the resulting graph
468 \param first iterator pointing to the first item in the dataset to use \f$ X_1 \f$
469 \param last iterator pointing behind the last item in the dataset to use \f$ X_N \f$
470 \param violinposY y-coordinate of the Violinplot
471 \param kernel the kernel function to use (e.g. jkqtpstatKernel1DGaussian() )
472 \param bandwidth bandwidth used for the KDE, if <0 then \c jkqtpstatEstimateKDEBandwidth(first,last) is called
473 \param minimumQuantile specifies a quantile for the return value minimum (default is 0 for the real minimum, but you could e.g. use 0.05 for the 5% quantile!)
474 \param maximumQuantile specifies a quantile for the return value maximum (default is 1 for the real maximum, but you could e.g. use 0.95 for the 95% quantile!)
475 \param distBasename name basing for added columns
476 \param violinDistSamples number of samples of the distribution (between min and max)
477 \return a Violinplot element with its values initialized from the given data range
478
479 Example:
480 \code
481 jkqtpstatAddHViolinplotKDEAndOutliers(plot->getPlotter(), datastore1->begin(randomdatacol1), datastore1->end(randomdatacol1), -15);
482 \endcode
483
484 \image html jkqtpstatAddHViolinplotKDEAndOutliers.png
485
486
487 \see \ref JKQTPlotterViolinplotGraphs, JKQTPViolinplotHorizontalElement, jkqtpstatKDE1DAutoranged()
488*/
489template <class InputIt>
490inline std::pair<JKQTPViolinplotHorizontalElement*,JKQTPSingleColumnSymbolsGraph*> jkqtpstatAddHViolinplotKDEAndOutliers(JKQTBasePlotter* plotter, InputIt first, InputIt last, double violinposY, const std::function<double(double)>& kernel=std::function<double(double)>(&jkqtpstatKernel1DGaussian), double bandwidth=-1, double minimumQuantile=0.03, double maximumQuantile=0.97, const QString& distBasename=QString("violin plot distribution"), int violinDistSamples=100) {
491 size_t cOutliersY=plotter->getDatastore()->addColumn(distBasename+", outliers, value");
492 std::vector<double> datain, datause;
493 std::copy(first, last, std::back_inserter(datain));
494 std::sort(datain.begin(), datain.end());
495 datause.reserve(datain.size());
496 size_t i0=jkqtp_boundedRoundTo<size_t>(0,minimumQuantile*static_cast<double>(datain.size()),datain.size()-1);
497 size_t i1=jkqtp_boundedRoundTo<size_t>(0,maximumQuantile*static_cast<double>(datain.size()),datain.size()-1);
498 for (size_t i=0; i<datain.size(); i++) {
499 if (i<=i0 || i>=i1) {
500 plotter->getDatastore()->appendToColumn(cOutliersY, datain[i]);
501 } else {
502 datause.push_back(datain[i]);
503 }
504 }
505
506
507
508 if (datause.size()>0) {
509 if (bandwidth<=0) bandwidth=jkqtpstatEstimateKDEBandwidth(datause.begin(), datause.end());
510 size_t cViol1Cat=plotter->getDatastore()->addColumn(distBasename+", category");
511 size_t cViol1Freq=plotter->getDatastore()->addColumn(distBasename+", KDE");
512 jkqtpstatKDE1DAutoranged(datause.begin(), datause.end(), plotter->getDatastore()->backInserter(cViol1Cat), plotter->getDatastore()->backInserter(cViol1Freq),
513 violinDistSamples, kernel, bandwidth);
515 res->setMin(datause[0]);
516 res->setMax(datause[datause.size()-1]);
518 res->setMean(jkqtpstatAverage(datause.begin(), datause.end()));
519 res->setDrawMean(true);
520 res->setDrawMedian(true);
521 res->setDrawMinMax(true);
522 res->setPos(violinposY);
523 res->setViolinPositionColumn(cViol1Cat);
524 res->setViolinFrequencyColumn(cViol1Freq);
525 plotter->addGraph(res);
526
528 resO->setDataColumn(cOutliersY);
529 resO->setPosition(violinposY);
532 resO->setColor(res->getKeyLabelColor());
533 resO->setTitle("");
534
535 plotter->addGraph(res);
536 plotter->addGraph(resO);
537 return std::pair<JKQTPViolinplotHorizontalElement*,JKQTPSingleColumnSymbolsGraph*>(res,resO);
538 } else {
539 return std::pair<JKQTPViolinplotHorizontalElement*,JKQTPSingleColumnSymbolsGraph*>(nullptr,nullptr);
540 }
541
542}
543
544
545
546
547
548/*! \brief add a JKQTPViolinplotHorizontalElement and an outliers graph to the given plotter, where the Violinplot values are calculated from the data range \a first ... \a last , uses a histogram as density distribution estimate
549 \ingroup jkqtptools_math_statistics_adaptors
550
551 \tparam InputIt standard iterator type of \a first and \a last.
552 \param plotter the plotter to which to add the resulting graph
553 \param first iterator pointing to the first item in the dataset to use \f$ X_1 \f$
554 \param last iterator pointing behind the last item in the dataset to use \f$ X_N \f$
555 \param violinposY y-coordinate of the Violinplot
556 \param minimumQuantile specifies a quantile for the return value minimum (default is 0 for the real minimum, but you could e.g. use 0.05 for the 5% quantile!)
557 \param maximumQuantile specifies a quantile for the return value maximum (default is 1 for the real maximum, but you could e.g. use 0.95 for the 95% quantile!)
558 \param distBasename name basing for added columns
559 \param violinDistSamples number of samples of the distribution (between min and max)
560 \return a Violinplot element with its values initialized from the given data range
561
562 Example:
563 \code
564 jkqtpstatAddHViolinplotHistogramAndOutliers(plot->getPlotter(), datastore1->begin(randomdatacol1), datastore1->end(randomdatacol1), -5);
565 \endcode
566
567 \image html jkqtpstatAddHViolinplotHistogramAndOutliers.png
568
569
570 \see \ref JKQTPlotterViolinplotGraphs, JKQTPViolinplotHorizontalElement, jkqtpstatHistogram1DAutoranged()
571*/
572template <class InputIt>
573inline std::pair<JKQTPViolinplotHorizontalElement*,JKQTPSingleColumnSymbolsGraph*> jkqtpstatAddHViolinplotHistogramAndOutliers(JKQTBasePlotter* plotter, InputIt first, InputIt last, double violinposY, double minimumQuantile=0.03, double maximumQuantile=0.97, const QString& distBasename=QString("violin plot distribution"), int violinDistSamples=21) {
574 size_t cOutliersY=plotter->getDatastore()->addColumn(distBasename+", outliers, value");
575 std::vector<double> datain, datause;
576 std::copy(first, last, std::back_inserter(datain));
577 std::sort(datain.begin(), datain.end());
578 datause.reserve(datain.size());
579 size_t i0=jkqtp_boundedRoundTo<size_t>(0,minimumQuantile*static_cast<double>(datain.size()),datain.size()-1);
580 size_t i1=jkqtp_boundedRoundTo<size_t>(0,maximumQuantile*static_cast<double>(datain.size()),datain.size()-1);
581 for (size_t i=0; i<datain.size(); i++) {
582 if (i<=i0 || i>=i1) {
583 plotter->getDatastore()->appendToColumn(cOutliersY, datain[i]);
584 } else {
585 datause.push_back(datain[i]);
586 }
587 }
588
589
590
591 if (datause.size()>0) {
592 size_t cViol1Cat=plotter->getDatastore()->addColumn(distBasename+", category");
593 size_t cViol1Freq=plotter->getDatastore()->addColumn(distBasename+", Histogram");
594 jkqtpstatHistogram1DAutoranged(datause.begin(), datause.end(), plotter->getDatastore()->backInserter(cViol1Cat), plotter->getDatastore()->backInserter(cViol1Freq), violinDistSamples);
596 res->setMin(datause[0]);
597 res->setMax(datause[datause.size()-1]);
599 res->setMean(jkqtpstatAverage(datause.begin(), datause.end()));
600 res->setDrawMean(true);
601 res->setDrawMedian(true);
602 res->setDrawMinMax(true);
603 res->setPos(violinposY);
604 res->setViolinPositionColumn(cViol1Cat);
605 res->setViolinFrequencyColumn(cViol1Freq);
607 plotter->addGraph(res);
608
610 resO->setDataColumn(cOutliersY);
611 resO->setPosition(violinposY);
614 resO->setColor(res->getKeyLabelColor());
615 resO->setTitle("");
616
617 plotter->addGraph(res);
618 plotter->addGraph(resO);
619 return std::pair<JKQTPViolinplotHorizontalElement*,JKQTPSingleColumnSymbolsGraph*>(res,resO);
620 } else {
621 return std::pair<JKQTPViolinplotHorizontalElement*,JKQTPSingleColumnSymbolsGraph*>(nullptr,nullptr);
622 }
623
624}
625
626
627
628
629
630
631
632
633
634/*! \brief add a JKQTPViolinplotVerticalElement and an outliers graph to the given plotter, where the Violinplot values are calculated from the data range \a first ... \a last , uses a kernel density estimate as density distribution estimate
635 \ingroup jkqtptools_math_statistics_adaptors
636
637 \tparam InputIt standard iterator type of \a first and \a last.
638 \param plotter the plotter to which to add the resulting graph
639 \param first iterator pointing to the first item in the dataset to use \f$ X_1 \f$
640 \param last iterator pointing behind the last item in the dataset to use \f$ X_N \f$
641 \param violinposY y-coordinate of the Violinplot
642 \param kernel the kernel function to use (e.g. jkqtpstatKernel1DGaussian() )
643 \param bandwidth bandwidth used for the KDE, if <0 then \c jkqtpstatEstimateKDEBandwidth(first,last) is called
644 \param minimumQuantile specifies a quantile for the return value minimum (default is 0 for the real minimum, but you could e.g. use 0.05 for the 5% quantile!)
645 \param maximumQuantile specifies a quantile for the return value maximum (default is 1 for the real maximum, but you could e.g. use 0.95 for the 95% quantile!)
646 \param distBasename name basing for added columns
647 \param violinDistSamples number of samples of the distribution (between min and max)
648 \return a Violinplot element with its values initialized from the given data range
649
650 Example:
651 \code
652 jkqtpstatAddVViolinplotKDEAndOutliers(plot->getPlotter(), datastore1->begin(randomdatacol1), datastore1->end(randomdatacol1), -15);
653 \endcode
654
655 \image html jkqtpstatAddVViolinplotKDEAndOutliers.png
656
657
658 \see \ref JKQTPlotterViolinplotGraphs, JKQTPViolinplotVerticalElement, jkqtpstatKDE1DAutoranged()
659*/
660template <class InputIt>
661inline std::pair<JKQTPViolinplotVerticalElement*,JKQTPSingleColumnSymbolsGraph*> jkqtpstatAddVViolinplotKDEAndOutliers(JKQTBasePlotter* plotter, InputIt first, InputIt last, double violinposY, const std::function<double(double)>& kernel=std::function<double(double)>(&jkqtpstatKernel1DGaussian), double bandwidth=-1, double minimumQuantile=0.03, double maximumQuantile=0.97, const QString& distBasename=QString("violin plot distribution"), int violinDistSamples=100) {
662 size_t cOutliersY=plotter->getDatastore()->addColumn(distBasename+", outliers, value");
663 std::vector<double> datain, datause;
664 std::copy(first, last, std::back_inserter(datain));
665 std::sort(datain.begin(), datain.end());
666 datause.reserve(datain.size());
667 size_t i0=jkqtp_boundedRoundTo<size_t>(0,minimumQuantile*static_cast<double>(datain.size()),datain.size()-1);
668 size_t i1=jkqtp_boundedRoundTo<size_t>(0,maximumQuantile*static_cast<double>(datain.size()),datain.size()-1);
669 for (size_t i=0; i<datain.size(); i++) {
670 if (i<=i0 || i>=i1) {
671 plotter->getDatastore()->appendToColumn(cOutliersY, datain[i]);
672 } else {
673 datause.push_back(datain[i]);
674 }
675 }
676
677
678
679 if (datause.size()>0) {
680 if (bandwidth<=0) bandwidth=jkqtpstatEstimateKDEBandwidth(datause.begin(), datause.end());
681 size_t cViol1Cat=plotter->getDatastore()->addColumn(distBasename+", category");
682 size_t cViol1Freq=plotter->getDatastore()->addColumn(distBasename+", KDE");
683 jkqtpstatKDE1DAutoranged(datause.begin(), datause.end(), plotter->getDatastore()->backInserter(cViol1Cat), plotter->getDatastore()->backInserter(cViol1Freq),
684 violinDistSamples, kernel, bandwidth);
686 res->setMin(datause[0]);
687 res->setMax(datause[datause.size()-1]);
689 res->setMean(jkqtpstatAverage(datause.begin(), datause.end()));
690 res->setDrawMean(true);
691 res->setDrawMedian(true);
692 res->setDrawMinMax(true);
693 res->setPos(violinposY);
694 res->setViolinPositionColumn(cViol1Cat);
695 res->setViolinFrequencyColumn(cViol1Freq);
696 plotter->addGraph(res);
697
699 resO->setDataColumn(cOutliersY);
700 resO->setPosition(violinposY);
703 resO->setColor(res->getKeyLabelColor());
704 resO->setTitle("");
705
706 plotter->addGraph(res);
707 plotter->addGraph(resO);
708 return std::pair<JKQTPViolinplotVerticalElement*,JKQTPSingleColumnSymbolsGraph*>(res,resO);
709 } else {
710 return std::pair<JKQTPViolinplotVerticalElement*,JKQTPSingleColumnSymbolsGraph*>(nullptr,nullptr);
711 }
712
713}
714
715
716
717
718
719/*! \brief add a JKQTPViolinplotVerticalElement and an outliers graph to the given plotter, where the Violinplot values are calculated from the data range \a first ... \a last , uses a histogram as density distribution estimate
720 \ingroup jkqtptools_math_statistics_adaptors
721
722 \tparam InputIt standard iterator type of \a first and \a last.
723 \param plotter the plotter to which to add the resulting graph
724 \param first iterator pointing to the first item in the dataset to use \f$ X_1 \f$
725 \param last iterator pointing behind the last item in the dataset to use \f$ X_N \f$
726 \param violinposY y-coordinate of the Violinplot
727 \param minimumQuantile specifies a quantile for the return value minimum (default is 0 for the real minimum, but you could e.g. use 0.05 for the 5% quantile!)
728 \param maximumQuantile specifies a quantile for the return value maximum (default is 1 for the real maximum, but you could e.g. use 0.95 for the 95% quantile!)
729 \param distBasename name basing for added columns
730 \param violinDistSamples number of samples of the distribution (between min and max)
731 \return a Violinplot element with its values initialized from the given data range
732
733 Example:
734 \code
735 jkqtpstatAddVViolinplotHistogramAndOutliers(plot->getPlotter(), datastore1->begin(randomdatacol1), datastore1->end(randomdatacol1), -5);
736 \endcode
737
738 \image html jkqtpstatAddVViolinplotHistogramAndOutliers.png
739
740
741 \see \ref JKQTPlotterViolinplotGraphs, JKQTPViolinplotVerticalElement, jkqtpstatHistogram1DAutoranged()
742*/
743template <class InputIt>
744inline std::pair<JKQTPViolinplotVerticalElement*,JKQTPSingleColumnSymbolsGraph*> jkqtpstatAddVViolinplotHistogramAndOutliers(JKQTBasePlotter* plotter, InputIt first, InputIt last, double violinposY, double minimumQuantile=0.03, double maximumQuantile=0.97, const QString& distBasename=QString("violin plot distribution"), int violinDistSamples=21) {
745 size_t cOutliersY=plotter->getDatastore()->addColumn(distBasename+", outliers, value");
746 std::vector<double> datain, datause;
747 std::copy(first, last, std::back_inserter(datain));
748 std::sort(datain.begin(), datain.end());
749 datause.reserve(datain.size());
750 size_t i0=jkqtp_boundedRoundTo<size_t>(0,minimumQuantile*static_cast<double>(datain.size()),datain.size()-1);
751 size_t i1=jkqtp_boundedRoundTo<size_t>(0,maximumQuantile*static_cast<double>(datain.size()),datain.size()-1);
752 for (size_t i=0; i<datain.size(); i++) {
753 if (i<=i0 || i>=i1) {
754 plotter->getDatastore()->appendToColumn(cOutliersY, datain[i]);
755 } else {
756 datause.push_back(datain[i]);
757 }
758 }
759
760
761
762 if (datause.size()>0) {
763 size_t cViol1Cat=plotter->getDatastore()->addColumn(distBasename+", category");
764 size_t cViol1Freq=plotter->getDatastore()->addColumn(distBasename+", Histogram");
765 jkqtpstatHistogram1DAutoranged(datause.begin(), datause.end(), plotter->getDatastore()->backInserter(cViol1Cat), plotter->getDatastore()->backInserter(cViol1Freq), violinDistSamples);
767 res->setMin(datause[0]);
768 res->setMax(datause[datause.size()-1]);
770 res->setMean(jkqtpstatAverage(datause.begin(), datause.end()));
771 res->setDrawMean(true);
772 res->setDrawMedian(true);
773 res->setDrawMinMax(true);
774 res->setPos(violinposY);
775 res->setViolinPositionColumn(cViol1Cat);
776 res->setViolinFrequencyColumn(cViol1Freq);
778 plotter->addGraph(res);
779
781 resO->setDataColumn(cOutliersY);
782 resO->setPosition(violinposY);
785 resO->setColor(res->getKeyLabelColor());
786 resO->setTitle("");
787
788 plotter->addGraph(res);
789 plotter->addGraph(resO);
790 return std::pair<JKQTPViolinplotVerticalElement*,JKQTPSingleColumnSymbolsGraph*>(res,resO);
791 } else {
792 return std::pair<JKQTPViolinplotVerticalElement*,JKQTPSingleColumnSymbolsGraph*>(nullptr,nullptr);
793 }
794
795}
796
797
798
799
800
801
802
803
804/*! \brief calculate an autoranged histogram and add a JKQTPBarVerticalGraph to the given plotter, where the histogram is calculated from the data range \a first ... \a last, bins defined by their number
805 \ingroup jkqtptools_math_statistics_adaptors
806
807
808 \tparam InputIt standard iterator type of \a first and \a last.
809 \param plotter the plotter to which to add the resulting graph
810 \param first iterator pointing to the first item in the dataset to use \f$ X_1 \f$
811 \param last iterator pointing behind the last item in the dataset to use \f$ X_N \f$
812 \param bins number of bins in the resulting histogram
813 \param histogramcolumnBaseName this string is used in building the column names for the outlier columns
814 \param normalized indicates whether the histogram has to be normalized
815 \param cummulative if \c true, a cummulative histogram is calculated
816 \return a graph class pointer (of type \a GraphClass ) displaying the histogram data
817
818 Example:
819 \code
820 jkqtpstatAddHHistogram1DAutoranged(plot1->getPlotter(), datastore1->begin(randomdatacol1), datastore1->end(randomdatacol1), 11);
821 \endcode
822
823 \image html datastore_statistics_hist.png
824
825 \see \ref JKQTPlotterBasicJKQTPDatastoreStatistics, jkqtpstatHistogram1DAutoranged(), JKQTPBarVerticalGraph
826*/
827template <class InputIt>
828inline JKQTPBarVerticalGraph* jkqtpstatAddHHistogram1DAutoranged(JKQTBasePlotter* plotter, InputIt first, InputIt last, int bins=11, bool normalized=true, bool cummulative=false, const QString& histogramcolumnBaseName=QString("histogram")) {
829 size_t histcolX=plotter->getDatastore()->addColumn(histogramcolumnBaseName+", bins");
830 size_t histcolY=plotter->getDatastore()->addColumn(histogramcolumnBaseName+", values");
831 jkqtpstatHistogram1DAutoranged(first, last, plotter->getDatastore()->backInserter(histcolX), plotter->getDatastore()->backInserter(histcolY), bins, normalized, cummulative, JKQTPStatHistogramBinXMode::XIsMid);
833 resO->setXColumn(histcolX);
834 resO->setYColumn(histcolY);
835 resO->setTitle(histogramcolumnBaseName);
836 plotter->addGraph(resO);
837 return resO;
838}
839
840
841
842/*! \brief calculate an autoranged histogram and add a JKQTPBarVerticalGraph to the given plotter, where the histogram is calculated from the data range \a first ... \a last, bins defined by their width
843 \ingroup jkqtptools_math_statistics_adaptors
844
845
846 \tparam InputIt standard iterator type of \a first and \a last.
847 \param plotter the plotter to which to add the resulting graph
848 \param first iterator pointing to the first item in the dataset to use \f$ X_1 \f$
849 \param last iterator pointing behind the last item in the dataset to use \f$ X_N \f$
850 \param binWidth width of the bins
851 \param histogramcolumnBaseName this string is used in building the column names for the histogram columns
852 \param normalized indicates whether the histogram has to be normalized
853 \param cummulative if \c true, a cummulative histogram is calculated
854 \return a graph class pointer (of type \a GraphClass ) displaying the histogram data
855
856 Example:
857 \code
858 jkqtpstatAddHHistogram1DAutoranged(plot1->getPlotter(), datastore1->begin(randomdatacol1), datastore1->end(randomdatacol1), 0.5);
859 \endcode
860
861 \image html datastore_statistics_hist.png
862
863 \see \ref JKQTPlotterBasicJKQTPDatastoreStatistics, jkqtpstatHistogram1DAutoranged(), JKQTPBarVerticalGraph
864*/
865template <class InputIt>
866inline JKQTPBarVerticalGraph* jkqtpstatAddHHistogram1DAutoranged(JKQTBasePlotter* plotter, InputIt first, InputIt last, double binWidth, bool normalized=true, bool cummulative=false, const QString& histogramcolumnBaseName=QString("histogram")) {
867 size_t histcolX=plotter->getDatastore()->addColumn(histogramcolumnBaseName+", bins");
868 size_t histcolY=plotter->getDatastore()->addColumn(histogramcolumnBaseName+", values");
869 jkqtpstatHistogram1DAutoranged(first, last, plotter->getDatastore()->backInserter(histcolX), plotter->getDatastore()->backInserter(histcolY), binWidth, normalized, cummulative, JKQTPStatHistogramBinXMode::XIsMid);
871 resO->setXColumn(histcolX);
872 resO->setYColumn(histcolY);
873 resO->setTitle(histogramcolumnBaseName);
874 plotter->addGraph(resO);
875 return resO;
876}
877
878
879/*! \brief calculate an autoranged histogram and add a JKQTPBarVerticalGraph to the given plotter, where the histogram is calculated from the data range \a first ... \a last, bins defined by their width
880 \ingroup jkqtptools_math_statistics_adaptors
881
882
883 \tparam InputIt standard iterator type of \a first and \a last.
884 \tparam BinsInputIt standard iterator type of \a binsFirst and \a binsLast.
885 \param plotter the plotter to which to add the resulting graph
886 \param first iterator pointing to the first item in the dataset to use \f$ X_1 \f$
887 \param last iterator pointing behind the last item in the dataset to use \f$ X_N \f$
888 \param binsFirst iterator pointing to the first item in the set of histogram bins
889 \param binsLast iterator pointing behind the last item in the set of histogram bins
890 \param histogramcolumnBaseName this string is used in building the column names for the histogram columns
891 \param normalized indicates whether the histogram has to be normalized
892 \param cummulative if \c true, a cummulative histogram is calculated
893 \return a graph class pointer (of type \a GraphClass ) displaying the histogram data
894
895 Example:
896 \code
897 std::vector<double> bins{-2,-1.5,-1,-0.75,-0.5,-0.25,0,0.25,0.5,0.75,1,1.5,2,2.5,3,4,5,6,7,8,9,10};
898 jkqtpstatAddHHistogram1D(plot1->getPlotter(), datastore1->begin(randomdatacol1), datastore1->end(randomdatacol1), bins.begin(), bins.end());
899 \endcode
900
901 \image html datastore_statistics_hist.png
902
903 \see \ref JKQTPlotterBasicJKQTPDatastoreStatistics, jkqtpstatHistogram1D(), JKQTPBarVerticalGraph
904*/
905template <class InputIt, class BinsInputIt>
906inline JKQTPBarVerticalGraph* jkqtpstatAddHHistogram1D(JKQTBasePlotter* plotter, InputIt first, InputIt last, BinsInputIt binsFirst, BinsInputIt binsLast, bool normalized=true, bool cummulative=false, const QString& histogramcolumnBaseName=QString("histogram")) {
907 size_t histcolX=plotter->getDatastore()->addColumn(histogramcolumnBaseName+", bins");
908 size_t histcolY=plotter->getDatastore()->addColumn(histogramcolumnBaseName+", values");
909 jkqtpstatHistogram1D(first, last, binsFirst, binsLast, plotter->getDatastore()->backInserter(histcolX), plotter->getDatastore()->backInserter(histcolY), normalized, cummulative, JKQTPStatHistogramBinXMode::XIsMid);
911 resO->setXColumn(histcolX);
912 resO->setYColumn(histcolY);
913 resO->setTitle(histogramcolumnBaseName);
914 plotter->addGraph(resO);
915 return resO;
916}
917
918
919/*! \brief calculate an autoranged histogram and add a JKQTPBarHorizontalGraph to the given plotter, where the histogram is calculated from the data range \a first ... \a last, bins defined by their number
920 \ingroup jkqtptools_math_statistics_adaptors
921
922
923 \tparam InputIt standard iterator type of \a first and \a last.
924 \param plotter the plotter to which to add the resulting graph
925 \param first iterator pointing to the first item in the dataset to use \f$ X_1 \f$
926 \param last iterator pointing behind the last item in the dataset to use \f$ X_N \f$
927 \param bins number of bins in the resulting histogram
928 \param histogramcolumnBaseName this string is used in building the column names for the histogram columns
929 \param normalized indicates whether the histogram has to be normalized
930 \param cummulative if \c true, a cummulative histogram is calculated
931 \return a graph class pointer (of type \a GraphClass ) displaying the histogram data
932
933 Example:
934 \code
935 jkqtpstatAddVHistogram1DAutoranged(plot1->getPlotter(), datastore1->begin(randomdatacol1), datastore1->end(randomdatacol1), 11);
936 \endcode
937
938 \see \ref JKQTPlotterBasicJKQTPDatastoreStatistics, jkqtpstatHistogram1DAutoranged(), JKQTPBarHorizontalGraph
939*/
940template <class InputIt>
941inline JKQTPBarHorizontalGraph* jkqtpstatAddVHistogram1DAutoranged(JKQTBasePlotter* plotter, InputIt first, InputIt last, int bins=11, bool normalized=true, bool cummulative=false, const QString& histogramcolumnBaseName=QString("histogram")) {
942 size_t histcolX=plotter->getDatastore()->addColumn(histogramcolumnBaseName+", bins");
943 size_t histcolY=plotter->getDatastore()->addColumn(histogramcolumnBaseName+", values");
944 jkqtpstatHistogram1DAutoranged(first, last, plotter->getDatastore()->backInserter(histcolX), plotter->getDatastore()->backInserter(histcolY), bins, normalized, cummulative, JKQTPStatHistogramBinXMode::XIsMid);
946 resO->setXColumn(histcolY);
947 resO->setYColumn(histcolX);
948 resO->setTitle(histogramcolumnBaseName);
949 plotter->addGraph(resO);
950 return resO;
951}
952
953
954
955/*! \brief calculate an autoranged histogram and add a JKQTPBarHorizontalGraph to the given plotter, where the histogram is calculated from the data range \a first ... \a last, bins defined by their width
956 \ingroup jkqtptools_math_statistics_adaptors
957
958
959 \tparam InputIt standard iterator type of \a first and \a last.
960 \param plotter the plotter to which to add the resulting graph
961 \param first iterator pointing to the first item in the dataset to use \f$ X_1 \f$
962 \param last iterator pointing behind the last item in the dataset to use \f$ X_N \f$
963 \param binWidth width of the bins
964 \param histogramcolumnBaseName this string is used in building the column names for the histogram columns
965 \param normalized indicates whether the histogram has to be normalized
966 \param cummulative if \c true, a cummulative histogram is calculated
967 \return a graph class pointer (of type \a GraphClass ) displaying the histogram data
968
969 Example:
970 \code
971 jkqtpstatAddVHistogram1DAutoranged(plot1->getPlotter(), datastore1->begin(randomdatacol1), datastore1->end(randomdatacol1), 0.5);
972 \endcode
973
974 \see \ref JKQTPlotterBasicJKQTPDatastoreStatistics, jkqtpstatHistogram1DAutoranged(), JKQTPBarHorizontalGraph
975*/
976template <class InputIt>
977inline JKQTPBarHorizontalGraph* jkqtpstatAddVHistogram1DAutoranged(JKQTBasePlotter* plotter, InputIt first, InputIt last, double binWidth, bool normalized=true, bool cummulative=false, const QString& histogramcolumnBaseName=QString("histogram")) {
978 size_t histcolX=plotter->getDatastore()->addColumn(histogramcolumnBaseName+", bins");
979 size_t histcolY=plotter->getDatastore()->addColumn(histogramcolumnBaseName+", values");
980 jkqtpstatHistogram1DAutoranged(first, last, plotter->getDatastore()->backInserter(histcolX), plotter->getDatastore()->backInserter(histcolY), binWidth, normalized, cummulative, JKQTPStatHistogramBinXMode::XIsMid);
982 resO->setXColumn(histcolY);
983 resO->setYColumn(histcolX);
984 resO->setTitle(histogramcolumnBaseName);
985 plotter->addGraph(resO);
986 return resO;
987}
988
989
990/*! \brief calculate an autoranged histogram and add a JKQTPBarHorizontalGraph to the given plotter, where the histogram is calculated from the data range \a first ... \a last, bins defined by their width
991 \ingroup jkqtptools_math_statistics_adaptors
992
993
994 \tparam InputIt standard iterator type of \a first and \a last.
995 \tparam BinsInputIt standard iterator type of \a binsFirst and \a binsLast.
996 \param plotter the plotter to which to add the resulting graph
997 \param first iterator pointing to the first item in the dataset to use \f$ X_1 \f$
998 \param last iterator pointing behind the last item in the dataset to use \f$ X_N \f$
999 \param binsFirst iterator pointing to the first item in the set of histogram bins
1000 \param binsLast iterator pointing behind the last item in the set of histogram bins
1001 \param histogramcolumnBaseName this string is used in building the column names for the histogram columns
1002 \param normalized indicates whether the histogram has to be normalized
1003 \param cummulative if \c true, a cummulative histogram is calculated
1004 \return a graph class pointer (of type \a GraphClass ) displaying the histogram data
1005
1006 Example:
1007 \code
1008 std::vector<double> bins{-2,-1.5,-1,-0.75,-0.5,-0.25,0,0.25,0.5,0.75,1,1.5,2,2.5,3,4,5,6,7,8,9,10};
1009 jkqtpstatAddVHistogram1D(plot1->getPlotter(), datastore1->begin(randomdatacol1), datastore1->end(randomdatacol1), bins.begin(), bins.end());
1010 \endcode
1011
1012 \see \ref JKQTPlotterBasicJKQTPDatastoreStatistics, jkqtpstatHistogram1D(), JKQTPBarHorizontalGraph
1013*/
1014template <class InputIt, class BinsInputIt>
1015inline JKQTPBarHorizontalGraph* jkqtpstatAddVHistogram1D(JKQTBasePlotter* plotter, InputIt first, InputIt last, BinsInputIt binsFirst, BinsInputIt binsLast, bool normalized=true, bool cummulative=false, const QString& histogramcolumnBaseName=QString("histogram")) {
1016 size_t histcolX=plotter->getDatastore()->addColumn(histogramcolumnBaseName+", bins");
1017 size_t histcolY=plotter->getDatastore()->addColumn(histogramcolumnBaseName+", values");
1018 jkqtpstatHistogram1D(first, last, binsFirst, binsLast, plotter->getDatastore()->backInserter(histcolX), plotter->getDatastore()->backInserter(histcolY), normalized, cummulative, JKQTPStatHistogramBinXMode::XIsMid);
1020 resO->setXColumn(histcolY);
1021 resO->setYColumn(histcolX);
1022 resO->setTitle(histogramcolumnBaseName);
1023 plotter->addGraph(resO);
1024 return resO;
1025}
1026
1027
1028
1029
1030
1031
1032
1033
1034/*! \brief calculate calculate a 2-dimensional histogram and add a JKQTPColumnMathImage to the given plotter, where the histogram is calculated from the given data range \a firstX / \a firstY ... \a lastY / \a lastY
1035 \ingroup jkqtptools_math_statistics_adaptors
1036
1037 \tparam InputItX standard iterator type of \a firstX and \a lastX.
1038 \tparam InputItY standard iterator type of \a firstY and \a lastY.
1039 \param plotter the plotter to which to add the resulting graph
1040 \param firstX iterator pointing to the first x-position item in the dataset to use \f$ X_1 \f$
1041 \param lastX iterator pointing behind the last x-position item in the dataset to use \f$ X_N \f$
1042 \param firstY iterator pointing to the first y-position item in the dataset to use \f$ Y_1 \f$
1043 \param lastY iterator pointing behind the last y-position item in the dataset to use \f$ Y_N \f$
1044 \param xbins number of bins in x-direction
1045 \param ybins number of bins in y-direction
1046 \param normalized indicates whether the histogram has to be normalized
1047 \param histogramcolumnBaseName this string is used in building the column names for the histogram data columns
1048 \param[out] oxmin position of the first histogram bin in x-direction
1049 \param[out] oxmax position of the last histogram bin in x-direction
1050 \param[out] oymin position of the first histogram bin in y-direction
1051 \param[out] oymax position of the last histogram bin in y-direction
1052 \return a graph class pointer (of type \c JKQTPColumnMathImage ) displaying the histogram data
1053
1054 \image html datastore_statistics_2d_hist.png
1055
1056 \see jkqtpstatHistogram2D(), \ref JKQTPlotterBasicJKQTPDatastoreStatistics2D
1057*/
1058template <class InputItX, class InputItY>
1059inline JKQTPColumnMathImage* jkqtpstatAddHistogram2DImage(JKQTBasePlotter* plotter, InputItX firstX, InputItX lastX, InputItY firstY, InputItY lastY, size_t xbins=10, size_t ybins=10, bool normalized=true, const QString& histogramcolumnBaseName=QString("histogram"), double* oxmin=nullptr, double* oxmax=nullptr, double* oymin=nullptr, double* oymax=nullptr) {
1060 double xmin=0, xmax=0;
1061 double ymin=0, ymax=0;
1062 jkqtpstatMinMax(firstX,lastX, xmin,xmax);
1063 jkqtpstatMinMax(firstY,lastY, ymin,ymax);
1064 size_t histcol=plotter->getDatastore()->addImageColumn(xbins, ybins, histogramcolumnBaseName);
1065 jkqtpstatHistogram2D(firstX,lastX,firstY,lastY,
1066 plotter->getDatastore()->begin(histcol),
1067 xmin, xmax, ymin, ymax,
1068 xbins, ybins, normalized);
1069 JKQTPColumnMathImage* gHist;
1070 plotter->addGraph(gHist=new JKQTPColumnMathImage(plotter));
1071 gHist->setImageColumn(static_cast<int>(histcol));
1072 gHist->setX(xmin);
1073 gHist->setY(ymin);
1074 gHist->setWidth(xmax-xmin);
1075 gHist->setHeight(ymax-ymin);
1076 gHist->setTitle(QObject::tr("2D Histogram"));
1077 if (oxmax) *oxmax=xmax;
1078 if (oxmin) *oxmin=xmin;
1079 if (oymax) *oymax=ymax;
1080 if (oymin) *oymin=ymin;
1081 return gHist;
1082}
1083
1084
1085
1086
1087
1088
1089/*! \brief calculate calculate a 2-dimensional histogram and add a JKQTPColumnContourPlot to the given plotter, where the histogram is calculated from the given data range \a firstX / \a firstY ... \a lastY / \a lastY
1090 \ingroup jkqtptools_math_statistics_adaptors
1091
1092 \tparam InputItX standard iterator type of \a firstX and \a lastX.
1093 \tparam InputItY standard iterator type of \a firstY and \a lastY.
1094 \param plotter the plotter to which to add the resulting graph
1095 \param firstX iterator pointing to the first x-position item in the dataset to use \f$ X_1 \f$
1096 \param lastX iterator pointing behind the last x-position item in the dataset to use \f$ X_N \f$
1097 \param firstY iterator pointing to the first y-position item in the dataset to use \f$ Y_1 \f$
1098 \param lastY iterator pointing behind the last y-position item in the dataset to use \f$ Y_N \f$
1099 \param xbins number of bins in x-direction
1100 \param ybins number of bins in y-direction
1101 \param normalized indicates whether the histogram has to be normalized
1102 \param histogramcolumnBaseName this string is used in building the column names for the histogram data columns
1103 \param[out] oxmin position of the first histogram bin in x-direction
1104 \param[out] oxmax position of the last histogram bin in x-direction
1105 \param[out] oymin position of the first histogram bin in y-direction
1106 \param[out] oymax position of the last histogram bin in y-direction
1107 \return a graph class pointer (of type \c JKQTPColumnContourPlot ) displaying the histogram data as a contour plot
1108
1109 \image html datastore_statistics_2d_histcontour.png
1110
1111 \see jkqtpstatHistogram2D(), \ref JKQTPlotterBasicJKQTPDatastoreStatistics2D
1112*/
1113template <class InputItX, class InputItY>
1114inline JKQTPColumnContourPlot* jkqtpstatAddHistogram2DContour(JKQTBasePlotter* plotter, InputItX firstX, InputItX lastX, InputItY firstY, InputItY lastY, size_t xbins=10, size_t ybins=10, bool normalized=true, const QString& histogramcolumnBaseName=QString("histogram"), double* oxmin=nullptr, double* oxmax=nullptr, double* oymin=nullptr, double* oymax=nullptr) {
1115 double xmin=0, xmax=0;
1116 double ymin=0, ymax=0;
1117 jkqtpstatMinMax(firstX,lastX, xmin,xmax);
1118 jkqtpstatMinMax(firstY,lastY, ymin,ymax);
1119 size_t histcol=plotter->getDatastore()->addImageColumn(xbins, ybins, histogramcolumnBaseName);
1120 jkqtpstatHistogram2D(firstX,lastX,firstY,lastY,
1121 plotter->getDatastore()->begin(histcol),
1122 xmin, xmax, ymin, ymax,
1123 xbins, ybins, true);
1125 plotter->addGraph(gHist=new JKQTPColumnContourPlot(plotter));
1126 gHist->setImageColumn(static_cast<int>(histcol));
1127 gHist->setX(xmin);
1128 gHist->setY(ymin);
1129 gHist->setWidth(xmax-xmin);
1130 gHist->setHeight(ymax-ymin);
1131 gHist->setTitle(QObject::tr("2D Histogram"));
1132 gHist->createContourLevels(5);
1133 if (oxmax) *oxmax=xmax;
1134 if (oxmin) *oxmin=xmin;
1135 if (oymax) *oymax=ymax;
1136 if (oymin) *oymin=ymin;
1137 return gHist;
1138}
1139/*! \brief calculate calculate a 2-dimensional histogram and add a JKQTPColumnMathImage to the given plotter, where the histogram is calculated from the given data range \a firstX / \a firstY ... \a lastY / \a lastY
1140 \ingroup jkqtptools_math_statistics_adaptors
1141
1142 \tparam InputItX standard iterator type of \a firstX and \a lastX.
1143 \tparam InputItY standard iterator type of \a firstY and \a lastY.
1144 \param plotter the plotter to which to add the resulting graph
1145 \param firstX iterator pointing to the first x-position item in the dataset to use \f$ X_1 \f$
1146 \param lastX iterator pointing behind the last x-position item in the dataset to use \f$ X_N \f$
1147 \param firstY iterator pointing to the first y-position item in the dataset to use \f$ Y_1 \f$
1148 \param lastY iterator pointing behind the last y-position item in the dataset to use \f$ Y_N \f$
1149 \param xbinwidth width of bins in x-direction
1150 \param ybinwidth width of bins in y-direction
1151 \param normalized indicates whether the histogram has to be normalized
1152 \param histogramcolumnBaseName this string is used in building the column names for the histogram data columns
1153 \param[out] oxmin position of the first histogram bin in x-direction
1154 \param[out] oxmax position of the last histogram bin in x-direction
1155 \param[out] oymin position of the first histogram bin in y-direction
1156 \param[out] oymax position of the last histogram bin in y-direction
1157 \return a graph class pointer (of type \c JKQTPColumnMathImage ) displaying the histogram data
1158
1159 \image html datastore_statistics_2d_hist.png
1160
1161 \see jkqtpstatHistogram2D(), \ref JKQTPlotterBasicJKQTPDatastoreStatistics2D
1162*/
1163template <class InputItX, class InputItY>
1164inline JKQTPColumnMathImage* jkqtpstatAddHistogram2DImage(JKQTBasePlotter* plotter, InputItX firstX, InputItX lastX, InputItY firstY, InputItY lastY, double xbinwidth, double ybinwidth, bool normalized=true, const QString& histogramcolumnBaseName=QString("histogram"), double* oxmin=nullptr, double* oxmax=nullptr, double* oymin=nullptr, double* oymax=nullptr) {
1165 double xmin=0, xmax=0;
1166 double ymin=0, ymax=0;
1167 jkqtpstatMinMax(firstX,lastX, xmin,xmax);
1168 jkqtpstatMinMax(firstY,lastY, ymin,ymax);
1169 size_t Nx=jkqtp_ceilTo<size_t>((xmax-xmin)/xbinwidth);
1170 size_t Ny=jkqtp_ceilTo<size_t>((ymax-ymin)/ybinwidth);
1171 size_t histcol=plotter->getDatastore()->addImageColumn(Nx, Ny, histogramcolumnBaseName);
1172 jkqtpstatHistogram2D(firstX,lastX,firstY,lastY,
1173 plotter->getDatastore()->begin(histcol),
1174 xmin, xmax, ymin, ymax,
1175 Nx, Ny, normalized);
1176 JKQTPColumnMathImage* gHist;
1177 plotter->addGraph(gHist=new JKQTPColumnMathImage(plotter));
1178 gHist->setImageColumn(static_cast<int>(histcol));
1179 gHist->setX(xmin);
1180 gHist->setY(ymin);
1181 gHist->setWidth(xmax-xmin);
1182 gHist->setHeight(ymax-ymin);
1183 gHist->setTitle(QObject::tr("2D Histogram"));
1184 if (oxmax) *oxmax=xmax;
1185 if (oxmin) *oxmin=xmin;
1186 if (oymax) *oymax=ymax;
1187 if (oymin) *oymin=ymin;
1188 return gHist;
1189}
1190
1191
1192
1193
1194
1195
1196/*! \brief calculate calculate a 2-dimensional histogram and add a JKQTPColumnContourPlot to the given plotter, where the histogram is calculated from the given data range \a firstX / \a firstY ... \a lastY / \a lastY
1197 \ingroup jkqtptools_math_statistics_adaptors
1198
1199 \tparam InputItX standard iterator type of \a firstX and \a lastX.
1200 \tparam InputItY standard iterator type of \a firstY and \a lastY.
1201 \param plotter the plotter to which to add the resulting graph
1202 \param firstX iterator pointing to the first x-position item in the dataset to use \f$ X_1 \f$
1203 \param lastX iterator pointing behind the last x-position item in the dataset to use \f$ X_N \f$
1204 \param firstY iterator pointing to the first y-position item in the dataset to use \f$ Y_1 \f$
1205 \param lastY iterator pointing behind the last y-position item in the dataset to use \f$ Y_N \f$
1206 \param xbinwidth width of bins in x-direction
1207 \param ybinwidth width of bins in y-direction
1208 \param normalized indicates whether the histogram has to be normalized
1209 \param histogramcolumnBaseName this string is used in building the column names for the histogram data columns
1210 \param[out] oxmin position of the first histogram bin in x-direction
1211 \param[out] oxmax position of the last histogram bin in x-direction
1212 \param[out] oymin position of the first histogram bin in y-direction
1213 \param[out] oymax position of the last histogram bin in y-direction
1214 \return a graph class pointer (of type \c JKQTPColumnContourPlot ) displaying the histogram data as a contour plot
1215
1216 \image html datastore_statistics_2d_histcontour.png
1217
1218 \see jkqtpstatHistogram2D(), \ref JKQTPlotterBasicJKQTPDatastoreStatistics2D
1219
1220*/
1221template <class InputItX, class InputItY>
1222inline JKQTPColumnContourPlot* jkqtpstatAddHistogram2DContour(JKQTBasePlotter* plotter, InputItX firstX, InputItX lastX, InputItY firstY, InputItY lastY, double xbinwidth, double ybinwidth, bool normalized=true, const QString& histogramcolumnBaseName=QString("histogram"), double* oxmin=nullptr, double* oxmax=nullptr, double* oymin=nullptr, double* oymax=nullptr) {
1223 double xmin=0, xmax=0;
1224 double ymin=0, ymax=0;
1225 jkqtpstatMinMax(firstX,lastX, xmin,xmax);
1226 jkqtpstatMinMax(firstY,lastY, ymin,ymax);
1227 size_t Nx=jkqtp_ceilTo<size_t>((xmax-xmin)/xbinwidth);
1228 size_t Ny=jkqtp_ceilTo<size_t>((ymax-ymin)/ybinwidth);
1229 size_t histcol=plotter->getDatastore()->addImageColumn(Nx, Ny, histogramcolumnBaseName);
1230 jkqtpstatHistogram2D(firstX,lastX,firstY,lastY,
1231 plotter->getDatastore()->begin(histcol),
1232 xmin, xmax, ymin, ymax,
1233 Nx, Ny, normalized);
1235 plotter->addGraph(gHist=new JKQTPColumnContourPlot(plotter));
1236 gHist->setImageColumn(static_cast<int>(histcol));
1237 gHist->setX(xmin);
1238 gHist->setY(ymin);
1239 gHist->setWidth(xmax-xmin);
1240 gHist->setHeight(ymax-ymin);
1241 gHist->setTitle(QObject::tr("2D Histogram"));
1242 gHist->createContourLevels(5);
1243 if (oxmax) *oxmax=xmax;
1244 if (oxmin) *oxmin=xmin;
1245 if (oymax) *oymax=ymax;
1246 if (oymin) *oymin=ymin;
1247 return gHist;
1248}
1249
1250
1251
1252
1253/*! \brief calculate an autoranged KDE and add a JKQTPXYLineGraph to the given plotter, where the KDE is calculated from the data range \a first ... \a last, bins defined by their number
1254 \ingroup jkqtptools_math_statistics_adaptors
1255
1256
1257 \tparam InputIt standard iterator type of \a first and \a last.
1258 \param plotter the plotter to which to add the resulting graph
1259 \param first iterator pointing to the first item in the dataset to use \f$ X_1 \f$
1260 \param last iterator pointing behind the last item in the dataset to use \f$ X_N \f$
1261 \param Nout number of points in the resulting KDE
1262 \param kernel the kernel function to use (e.g. jkqtpstatKernel1DGaussian() )
1263 \param bandwidth bandwidth used for the KDE
1264 \param cummulative if \c true, a cummulative KDE is calculated
1265 \param KDEcolumnBaseName this string is used in building the column names for the KDE data columns
1266 \return a graph class pointer (of type \a GraphClass ) displaying the KDE data
1267
1268 Example:
1269 \code
1270 jkqtpstatAddHKDE1DAutoranged(plot1->getPlotter(), datastore1->begin(randomdatacol1), datastore1->end(randomdatacol1), 200);
1271 \endcode
1272
1273 \image html datastore_statistics_kde.png
1274
1275
1276 \see \ref JKQTPlotterBasicJKQTPDatastoreStatistics, jkqtpstatKDE1DAutoranged(), JKQTPXYLineGraph
1277*/
1278template <class InputIt>
1279inline JKQTPXYLineGraph* jkqtpstatAddHKDE1DAutoranged(JKQTBasePlotter* plotter, InputIt first, InputIt last, int Nout=100, const std::function<double(double)>& kernel=std::function<double(double)>(&jkqtpstatKernel1DGaussian), double bandwidth=1.0, bool cummulative=false, const QString& KDEcolumnBaseName=QString("KDE")) {
1280 size_t histcolX=plotter->getDatastore()->addColumn(KDEcolumnBaseName+", positions");
1281 size_t histcolY=plotter->getDatastore()->addColumn(KDEcolumnBaseName+", values");
1282 jkqtpstatKDE1DAutoranged(first, last, plotter->getDatastore()->backInserter(histcolX), plotter->getDatastore()->backInserter(histcolY), Nout, kernel, bandwidth, cummulative);
1283 JKQTPXYLineGraph* resO=new JKQTPXYLineGraph(plotter);
1284 resO->setXColumn(histcolX);
1285 resO->setYColumn(histcolY);
1286 resO->setTitle(KDEcolumnBaseName);
1287 resO->setDrawLine(true);
1289 plotter->addGraph(resO);
1290 return resO;
1291}
1292
1293
1294
1295/*! \brief calculate an autoranged KDE and add a JKQTPXYLineGraph to the given plotter, where the KDE is calculated from the data range \a first ... \a last, bins defined by their width
1296 \ingroup jkqtptools_math_statistics_adaptors
1297
1298
1299 \tparam InputIt standard iterator type of \a first and \a last.
1300 \param plotter the plotter to which to add the resulting graph
1301 \param first iterator pointing to the first item in the dataset to use \f$ X_1 \f$
1302 \param last iterator pointing behind the last item in the dataset to use \f$ X_N \f$
1303 \param binWidth width of the bins
1304 \param kernel the kernel function to use (e.g. jkqtpstatKernel1DGaussian() )
1305 \param bandwidth bandwidth used for the KDE
1306 \param cummulative if \c true, a cummulative KDE is calculated
1307 \param KDEcolumnBaseName this string is used in building the column names for the KDE data columns
1308 \return a graph class pointer (of type \a GraphClass ) displaying the KDE data
1309
1310 Example:
1311 \code
1312 jkqtpstatAddHKDE1DAutoranged(plot1->getPlotter(), datastore1->begin(randomdatacol1), datastore1->end(randomdatacol1), 0.01);
1313 \endcode
1314
1315 \image html datastore_statistics_kde.png
1316
1317
1318 \see \ref JKQTPlotterBasicJKQTPDatastoreStatistics, jkqtpstatKDE1DAutoranged(), JKQTPXYLineGraph
1319*/
1320template <class InputIt>
1321inline JKQTPXYLineGraph* jkqtpstatAddHKDE1DAutoranged(JKQTBasePlotter* plotter, InputIt first, InputIt last, double binWidth, const std::function<double(double)>& kernel=std::function<double(double)>(&jkqtpstatKernel1DGaussian), double bandwidth=1.0, bool cummulative=false, const QString& KDEcolumnBaseName=QString("KDE")) {
1322 size_t histcolX=plotter->getDatastore()->addColumn(KDEcolumnBaseName+", bins");
1323 size_t histcolY=plotter->getDatastore()->addColumn(KDEcolumnBaseName+", values");
1324 jkqtpstatKDE1DAutoranged(first, last, plotter->getDatastore()->backInserter(histcolX), plotter->getDatastore()->backInserter(histcolY), binWidth, kernel, bandwidth, cummulative);
1325 JKQTPXYLineGraph* resO=new JKQTPXYLineGraph(plotter);
1326 resO->setXColumn(histcolX);
1327 resO->setYColumn(histcolY);
1328 resO->setTitle(KDEcolumnBaseName);
1329 resO->setDrawLine(true);
1331 plotter->addGraph(resO);
1332 return resO;
1333}
1334
1335
1336/*! \brief calculate an autoranged KDE and add a JKQTPXYLineGraph to the given plotter, where the KDE is calculated from the data range \a first ... \a last, bins defined by their width
1337 \ingroup jkqtptools_math_statistics_adaptors
1338
1339
1340 \tparam InputIt standard iterator type of \a first and \a last.
1341 \tparam BinsInputIt standard iterator type of \a binsFirst and \a binsLast.
1342 \param plotter the plotter to which to add the resulting graph
1343 \param first iterator pointing to the first item in the dataset to use \f$ X_1 \f$
1344 \param last iterator pointing behind the last item in the dataset to use \f$ X_N \f$
1345 \param binsFirst iterator pointing to the first item in the set of KDE bins
1346 \param binsLast iterator pointing behind the last item in the set of KDE bins
1347 \param kernel the kernel function to use (e.g. jkqtpstatKernel1DGaussian() )
1348 \param bandwidth bandwidth used for the KDE
1349 \param cummulative if \c true, a cummulative KDE is calculated
1350 \param KDEcolumnBaseName this string is used in building the column names for the KDE data columns
1351 \return a graph class pointer (of type \a GraphClass ) displaying the KDE data
1352
1353 Example:
1354 \code
1355 std::vector<double> bins{-2,-1.5,-1,-0.75,-0.5,-0.25,0,0.25,0.5,0.75,1,1.5,2,2.5,3,4,5,6,7,8,9,10};
1356 jkqtpstatAddHKDE1D(plot1->getPlotter(), datastore1->begin(randomdatacol1), datastore1->end(randomdatacol1), bins.begin(), bins.end());
1357 \endcode
1358
1359 \image html datastore_statistics_kde.png
1360
1361
1362 \see \ref JKQTPlotterBasicJKQTPDatastoreStatistics, jkqtpstatKDE1D(), JKQTPXYLineGraph
1363*/
1364template <class InputIt, class BinsInputIt>
1365inline JKQTPXYLineGraph* jkqtpstatAddHKDE1D(JKQTBasePlotter* plotter, InputIt first, InputIt last, BinsInputIt binsFirst, BinsInputIt binsLast, const std::function<double(double)>& kernel=std::function<double(double)>(&jkqtpstatKernel1DGaussian), double bandwidth=1.0, bool cummulative=false, const QString& KDEcolumnBaseName=QString("KDE")) {
1366 size_t histcolX=plotter->getDatastore()->addColumn(KDEcolumnBaseName+", bins");
1367 size_t histcolY=plotter->getDatastore()->addColumn(KDEcolumnBaseName+", values");
1368 jkqtpstatKDE1D(first, last, binsFirst, binsLast, plotter->getDatastore()->backInserter(histcolX), plotter->getDatastore()->backInserter(histcolY), kernel, bandwidth, cummulative);
1369 JKQTPXYLineGraph* resO=new JKQTPXYLineGraph(plotter);
1370 resO->setXColumn(histcolX);
1371 resO->setYColumn(histcolY);
1372 resO->setTitle(KDEcolumnBaseName);
1373 resO->setDrawLine(true);
1375 plotter->addGraph(resO);
1376 return resO;
1377}
1378
1379/*! \brief calculate an autoranged KDE and add a JKQTPXYLineGraph to the given plotter, where the KDE is calculated from the data range \a first ... \a last, evaluation positions are given by the range \a binXLeft ... \a binXRight (in steps of \a binxDelta )
1380 \ingroup jkqtptools_math_statistics_adaptors
1381
1382
1383 \tparam InputIt standard iterator type of \a first and \a last.
1384 \param plotter the plotter to which to add the resulting graph
1385 \param first iterator pointing to the first item in the dataset to use \f$ X_1 \f$
1386 \param last iterator pointing behind the last item in the dataset to use \f$ X_N \f$
1387 \param binXLeft first x-position, where to evaluate the KDE
1388 \param binXDelta distance between two x-positions at which the KDE is evaluated
1389 \param binXRight last x-position, where to evaluate the KDE
1390 \param kernel the kernel function to use (e.g. jkqtpstatKernel1DGaussian() )
1391 \param bandwidth bandwidth used for the KDE
1392 \param cummulative if \c true, a cummulative KDE is calculated
1393 \param KDEcolumnBaseName this string is used in building the column names for the KDE data columns
1394 \return a graph class pointer (of type \a GraphClass ) displaying the KDE data
1395
1396 Example:
1397 \code
1398 std::vector<double> bins{-2,-1.5,-1,-0.75,-0.5,-0.25,0,0.25,0.5,0.75,1,1.5,2,2.5,3,4,5,6,7,8,9,10};
1399 jkqtpstatAddHKDE1D(plot1->getPlotter(), datastore1->begin(randomdatacol1), datastore1->end(randomdatacol1), bins.begin(), bins.end());
1400 \endcode
1401
1402 \image html datastore_statistics_kde.png
1403
1404 \see \ref JKQTPlotterBasicJKQTPDatastoreStatistics, jkqtpstatKDE1D(), JKQTPXYLineGraph
1405*/
1406template <class InputIt>
1407inline JKQTPXYLineGraph* jkqtpstatAddHKDE1D(JKQTBasePlotter* plotter, InputIt first, InputIt last, double binXLeft, double binXDelta, double binXRight, const std::function<double(double)>& kernel=std::function<double(double)>(&jkqtpstatKernel1DGaussian), double bandwidth=1.0, bool cummulative=false, const QString& KDEcolumnBaseName=QString("KDE")) {
1408 size_t histcolX=plotter->getDatastore()->addColumn(KDEcolumnBaseName+", bins");
1409 size_t histcolY=plotter->getDatastore()->addColumn(KDEcolumnBaseName+", values");
1410 jkqtpstatKDE1D(first, last, binXLeft, binXDelta, binXRight, plotter->getDatastore()->backInserter(histcolX), plotter->getDatastore()->backInserter(histcolY), kernel, bandwidth, cummulative);
1411 JKQTPXYLineGraph* resO=new JKQTPXYLineGraph(plotter);
1412 resO->setXColumn(histcolX);
1413 resO->setYColumn(histcolY);
1414 resO->setTitle(KDEcolumnBaseName);
1415 resO->setDrawLine(true);
1417 plotter->addGraph(resO);
1418 return resO;
1419}
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431/*! \brief calculate an autoranged vertical KDE and add a JKQTPXYLineGraph to the given plotter, where the KDE is calculated from the data range \a first ... \a last, bins defined by their number
1432 \ingroup jkqtptools_math_statistics_adaptors
1433
1434
1435 \tparam InputIt standard iterator type of \a first and \a last.
1436 \param plotter the plotter to which to add the resulting graph
1437 \param first iterator pointing to the first item in the dataset to use \f$ X_1 \f$
1438 \param last iterator pointing behind the last item in the dataset to use \f$ X_N \f$
1439 \param Nout number of points in the resulting KDE
1440 \param kernel the kernel function to use (e.g. jkqtpstatKernel1DGaussian() )
1441 \param bandwidth bandwidth used for the KDE
1442 \param cummulative if \c true, a cummulative KDE is calculated
1443 \param KDEcolumnBaseName this string is used in building the column names for the KDE data columns
1444 \return a graph class pointer (of type \a GraphClass ) displaying the KDE data
1445
1446 Example:
1447 \code
1448 jkqtpstatAddVKDE1DAutoranged(plot1->getPlotter(), datastore1->begin(randomdatacol1), datastore1->end(randomdatacol1), 200);
1449 \endcode
1450
1451 \image html datastore_statistics_kde.png
1452
1453
1454 \see \ref JKQTPlotterBasicJKQTPDatastoreStatistics, jkqtpstatKDE1DAutoranged(), JKQTPXYLineGraph
1455*/
1456template <class InputIt>
1457inline JKQTPXYLineGraph* jkqtpstatAddVKDE1DAutoranged(JKQTBasePlotter* plotter, InputIt first, InputIt last, int Nout=100, const std::function<double(double)>& kernel=std::function<double(double)>(&jkqtpstatKernel1DGaussian), double bandwidth=1.0, bool cummulative=false, const QString& KDEcolumnBaseName=QString("KDE")) {
1458 size_t histcolX=plotter->getDatastore()->addColumn(KDEcolumnBaseName+", positions");
1459 size_t histcolY=plotter->getDatastore()->addColumn(KDEcolumnBaseName+", values");
1460 jkqtpstatKDE1DAutoranged(first, last, plotter->getDatastore()->backInserter(histcolX), plotter->getDatastore()->backInserter(histcolY), Nout, kernel, bandwidth, cummulative);
1461 JKQTPXYLineGraph* resO=new JKQTPXYLineGraph(plotter);
1462 resO->setXColumn(histcolY);
1463 resO->setYColumn(histcolX);
1464 resO->setTitle(KDEcolumnBaseName);
1465 resO->setDrawLine(true);
1467 plotter->addGraph(resO);
1468 return resO;
1469}
1470
1471
1472
1473/*! \brief calculate an autoranged vertical KDE and add a JKQTPXYLineGraph to the given plotter, where the KDE is calculated from the data range \a first ... \a last, bins defined by their width
1474 \ingroup jkqtptools_math_statistics_adaptors
1475
1476
1477 \tparam InputIt standard iterator type of \a first and \a last.
1478 \param plotter the plotter to which to add the resulting graph
1479 \param first iterator pointing to the first item in the dataset to use \f$ X_1 \f$
1480 \param last iterator pointing behind the last item in the dataset to use \f$ X_N \f$
1481 \param binWidth width of the bins
1482 \param kernel the kernel function to use (e.g. jkqtpstatKernel1DGaussian() )
1483 \param bandwidth bandwidth used for the KDE
1484 \param cummulative if \c true, a cummulative KDE is calculated
1485 \param KDEcolumnBaseName this string is used in building the column names for the KDE data columns
1486 \return a graph class pointer (of type \a GraphClass ) displaying the KDE data
1487
1488 Example:
1489 \code
1490 jkqtpstatAddVKDE1DAutoranged(plot1->getPlotter(), datastore1->begin(randomdatacol1), datastore1->end(randomdatacol1), 0.01);
1491 \endcode
1492
1493 \image html datastore_statistics_kde.png
1494
1495
1496 \see \ref JKQTPlotterBasicJKQTPDatastoreStatistics, jkqtpstatKDE1DAutoranged(), JKQTPXYLineGraph
1497*/
1498template <class InputIt>
1499inline JKQTPXYLineGraph* jkqtpstatAddVKDE1DAutoranged(JKQTBasePlotter* plotter, InputIt first, InputIt last, double binWidth, const std::function<double(double)>& kernel=std::function<double(double)>(&jkqtpstatKernel1DGaussian), double bandwidth=1.0, bool cummulative=false, const QString& KDEcolumnBaseName=QString("KDE")) {
1500 size_t histcolX=plotter->getDatastore()->addColumn(KDEcolumnBaseName+", bins");
1501 size_t histcolY=plotter->getDatastore()->addColumn(KDEcolumnBaseName+", values");
1502 jkqtpstatKDE1DAutoranged(first, last, plotter->getDatastore()->backInserter(histcolX), plotter->getDatastore()->backInserter(histcolY), binWidth, kernel, bandwidth, cummulative);
1503 JKQTPXYLineGraph* resO=new JKQTPXYLineGraph(plotter);
1504 resO->setXColumn(histcolY);
1505 resO->setYColumn(histcolX);
1506 resO->setTitle(KDEcolumnBaseName);
1507 resO->setDrawLine(true);
1509 plotter->addGraph(resO);
1510 return resO;
1511}
1512
1513
1514/*! \brief calculate an autoranged vertical KDE and add a JKQTPXYLineGraph to the given plotter, where the KDE is calculated from the data range \a first ... \a last, bins defined by their width
1515 \ingroup jkqtptools_math_statistics_adaptors
1516
1517
1518 \tparam InputIt standard iterator type of \a first and \a last.
1519 \tparam BinsInputIt standard iterator type of \a binsFirst and \a binsLast.
1520 \param plotter the plotter to which to add the resulting graph
1521 \param first iterator pointing to the first item in the dataset to use \f$ X_1 \f$
1522 \param last iterator pointing behind the last item in the dataset to use \f$ X_N \f$
1523 \param binsFirst iterator pointing to the first item in the set of KDE bins
1524 \param binsLast iterator pointing behind the last item in the set of KDE bins
1525 \param kernel the kernel function to use (e.g. jkqtpstatKernel1DGaussian() )
1526 \param bandwidth bandwidth used for the KDE
1527 \param cummulative if \c true, a cummulative KDE is calculated
1528 \param KDEcolumnBaseName this string is used in building the column names for the KDE data columns
1529 \return a graph class pointer (of type \a GraphClass ) displaying the KDE data
1530
1531 Example:
1532 \code
1533 std::vector<double> bins{-2,-1.5,-1,-0.75,-0.5,-0.25,0,0.25,0.5,0.75,1,1.5,2,2.5,3,4,5,6,7,8,9,10};
1534 jkqtpstatAddVKDE1D(plot1->getPlotter(), datastore1->begin(randomdatacol1), datastore1->end(randomdatacol1), bins.begin(), bins.end());
1535 \endcode
1536
1537 \image html datastore_statistics_kde.png
1538
1539
1540 \see \ref JKQTPlotterBasicJKQTPDatastoreStatistics, jkqtpstatKDE1D(), JKQTPXYLineGraph
1541*/
1542template <class InputIt, class BinsInputIt>
1543inline JKQTPXYLineGraph* jkqtpstatAddVKDE1D(JKQTBasePlotter* plotter, InputIt first, InputIt last, BinsInputIt binsFirst, BinsInputIt binsLast, const std::function<double(double)>& kernel=std::function<double(double)>(&jkqtpstatKernel1DGaussian), double bandwidth=1.0, bool cummulative=false, const QString& KDEcolumnBaseName=QString("KDE")) {
1544 size_t histcolX=plotter->getDatastore()->addColumn(KDEcolumnBaseName+", bins");
1545 size_t histcolY=plotter->getDatastore()->addColumn(KDEcolumnBaseName+", values");
1546 jkqtpstatKDE1D(first, last, binsFirst, binsLast, plotter->getDatastore()->backInserter(histcolX), plotter->getDatastore()->backInserter(histcolY), kernel, bandwidth, cummulative);
1547 JKQTPXYLineGraph* resO=new JKQTPXYLineGraph(plotter);
1548 resO->setXColumn(histcolY);
1549 resO->setYColumn(histcolX);
1550 resO->setTitle(KDEcolumnBaseName);
1551 resO->setDrawLine(true);
1553 plotter->addGraph(resO);
1554 return resO;
1555}
1556
1557/*! \brief calculate an autoranged vertical KDE and add a JKQTPXYLineGraph to the given plotter, where the KDE is calculated from the data range \a first ... \a last, evaluation positions are given by the range \a binXLeft ... \a binXRight (in steps of \a binxDelta )
1558 \ingroup jkqtptools_math_statistics_adaptors
1559
1560
1561 \tparam InputIt standard iterator type of \a first and \a last.
1562 \param plotter the plotter to which to add the resulting graph
1563 \param first iterator pointing to the first item in the dataset to use \f$ X_1 \f$
1564 \param last iterator pointing behind the last item in the dataset to use \f$ X_N \f$
1565 \param binXLeft first x-position, where to evaluate the KDE
1566 \param binXDelta distance between two x-positions at which the KDE is evaluated
1567 \param binXRight last x-position, where to evaluate the KDE
1568 \param kernel the kernel function to use (e.g. jkqtpstatKernel1DGaussian() )
1569 \param bandwidth bandwidth used for the KDE
1570 \param cummulative if \c true, a cummulative KDE is calculated
1571 \param KDEcolumnBaseName this string is used in building the column names for the KDE data columns
1572 \return a graph class pointer (of type \a GraphClass ) displaying the KDE data
1573
1574 Example:
1575 \code
1576 std::vector<double> bins{-2,-1.5,-1,-0.75,-0.5,-0.25,0,0.25,0.5,0.75,1,1.5,2,2.5,3,4,5,6,7,8,9,10};
1577 jkqtpstatAddVKDE1D(plot1->getPlotter(), datastore1->begin(randomdatacol1), datastore1->end(randomdatacol1), bins.begin(), bins.end());
1578 \endcode
1579
1580 \image html datastore_statistics_kde.png
1581
1582 \see \ref JKQTPlotterBasicJKQTPDatastoreStatistics, jkqtpstatKDE1D(), JKQTPXYLineGraph
1583*/
1584template <class InputIt>
1585inline JKQTPXYLineGraph* jkqtpstatAddVKDE1D(JKQTBasePlotter* plotter, InputIt first, InputIt last, double binXLeft, double binXDelta, double binXRight, const std::function<double(double)>& kernel=std::function<double(double)>(&jkqtpstatKernel1DGaussian), double bandwidth=1.0, bool cummulative=false, const QString& KDEcolumnBaseName=QString("KDE")) {
1586 size_t histcolX=plotter->getDatastore()->addColumn(KDEcolumnBaseName+", bins");
1587 size_t histcolY=plotter->getDatastore()->addColumn(KDEcolumnBaseName+", values");
1588 jkqtpstatKDE1D(first, last, binXLeft, binXDelta, binXRight, plotter->getDatastore()->backInserter(histcolX), plotter->getDatastore()->backInserter(histcolY), kernel, bandwidth, cummulative);
1589 JKQTPXYLineGraph* resO=new JKQTPXYLineGraph(plotter);
1590 resO->setXColumn(histcolY);
1591 resO->setYColumn(histcolX);
1592 resO->setTitle(KDEcolumnBaseName);
1593 resO->setDrawLine(true);
1595 plotter->addGraph(resO);
1596 return resO;
1597}
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613/*! \brief calculate calculate a 2-dimensional kernel density estimate (KDE) and add a JKQTPColumnMathImage to the given plotter, where the KDE is calculated from the given data range \a firstX / \a firstY ... \a lastY / \a lastY
1614 \ingroup jkqtptools_math_statistics_adaptors
1615
1616 \tparam InputItX standard iterator type of \a firstX and \a lastX.
1617 \tparam InputItY standard iterator type of \a firstY and \a lastY.
1618 \param plotter the plotter to which to add the resulting graph
1619 \param firstX iterator pointing to the first x-position item in the dataset to use \f$ X_1 \f$
1620 \param lastX iterator pointing behind the last x-position item in the dataset to use \f$ X_N \f$
1621 \param firstY iterator pointing to the first y-position item in the dataset to use \f$ Y_1 \f$
1622 \param lastY iterator pointing behind the last y-position item in the dataset to use \f$ Y_N \f$
1623 \param xbins number of bins in x-direction (i.e. width of the output KDE)
1624 \param ybins number of bins in y-direction (i.e. height of the output KDE)
1625 \param kernel the kernel function to use (e.g. jkqtpstatKernel2DGaussian() )
1626 \param bandwidthX x-bandwidth used for the KDE
1627 \param bandwidthY y-bandwidth used for the KDE
1628 \param kdecolumnBaseName this string is used in building the column names for the KDE data columns
1629 \param[out] oxmin position of the first KDE bin in x-direction
1630 \param[out] oxmax position of the last KDE bin in x-direction
1631 \param[out] oymin position of the first KDE bin in y-direction
1632 \param[out] oymax position of the last KDE bin in y-direction
1633 \return a graph class pointer (of type \c JKQTPColumnMathImage ) displaying the KDE data
1634
1635 \image html datastore_statistics_2d_kde.png
1636
1637 \see jkqtpstatKDE2D(), \ref JKQTPlotterBasicJKQTPDatastoreStatistics2D
1638*/
1639template <class InputItX, class InputItY>
1640inline JKQTPColumnMathImage* jkqtpstatAddKDE2DImage(JKQTBasePlotter* plotter, InputItX firstX, InputItX lastX, InputItY firstY, InputItY lastY, size_t xbins=10, size_t ybins=10, const std::function<double(double,double)>& kernel=std::function<double(double,double)>(&jkqtpstatKernel2DGaussian), double bandwidthX=1.0, double bandwidthY=1.0, const QString& kdecolumnBaseName=QString("histogram"), double* oxmin=nullptr, double* oxmax=nullptr, double* oymin=nullptr, double* oymax=nullptr) {
1641 double xmin=0, xmax=0;
1642 double ymin=0, ymax=0;
1643 jkqtpstatMinMax(firstX,lastX, xmin,xmax);
1644 jkqtpstatMinMax(firstY,lastY, ymin,ymax);
1645 size_t histcol=plotter->getDatastore()->addImageColumn(xbins, ybins, kdecolumnBaseName);
1646 jkqtpstatKDE2D(firstX,lastX,firstY,lastY,
1647 plotter->getDatastore()->begin(histcol),
1648 xmin, xmax, ymin, ymax,
1649 xbins, ybins, kernel, bandwidthX, bandwidthY);
1650 JKQTPColumnMathImage* gHist;
1651 plotter->addGraph(gHist=new JKQTPColumnMathImage(plotter));
1652 gHist->setImageColumn(static_cast<int>(histcol));
1653 gHist->setX(xmin);
1654 gHist->setY(ymin);
1655 gHist->setWidth(xmax-xmin);
1656 gHist->setHeight(ymax-ymin);
1657 gHist->setTitle(QObject::tr("2D KDE"));
1658 if (oxmax) *oxmax=xmax;
1659 if (oxmin) *oxmin=xmin;
1660 if (oymax) *oymax=ymax;
1661 if (oymin) *oymin=ymin;
1662 return gHist;
1663}
1664
1665
1666
1667
1668
1669
1670/*! \brief calculate calculate a 2-dimensional kernel density estimate (KDE) and add a JKQTPColumnContourPlot to the given plotter, where the KDE is calculated from the given data range \a firstX / \a firstY ... \a lastY / \a lastY
1671 \ingroup jkqtptools_math_statistics_adaptors
1672
1673 \tparam InputItX standard iterator type of \a firstX and \a lastX.
1674 \tparam InputItY standard iterator type of \a firstY and \a lastY.
1675 \param plotter the plotter to which to add the resulting graph
1676 \param firstX iterator pointing to the first x-position item in the dataset to use \f$ X_1 \f$
1677 \param lastX iterator pointing behind the last x-position item in the dataset to use \f$ X_N \f$
1678 \param firstY iterator pointing to the first y-position item in the dataset to use \f$ Y_1 \f$
1679 \param lastY iterator pointing behind the last y-position item in the dataset to use \f$ Y_N \f$
1680 \param xbins number of bins in x-direction (i.e. width of the output KDE)
1681 \param ybins number of bins in y-direction (i.e. height of the output KDE)
1682 \param kernel the kernel function to use (e.g. jkqtpstatKernel2DGaussian() )
1683 \param bandwidthX x-bandwidth used for the KDE
1684 \param bandwidthY y-bandwidth used for the KDE
1685 \param kdecolumnBaseName this string is used in building the column names for the KDE data columns
1686 \param[out] oxmin position of the first KDE bin in x-direction
1687 \param[out] oxmax position of the last KDE bin in x-direction
1688 \param[out] oymin position of the first KDE bin in y-direction
1689 \param[out] oymax position of the last KDE bin in y-direction
1690 \return a graph class pointer (of type \c JKQTPColumnContourPlot ) displaying the KDE data as a contour plot
1691
1692 \image html datastore_statistics_2d_kdecontour.png
1693
1694 \see jkqtpstatKDE2D(), \ref JKQTPlotterBasicJKQTPDatastoreStatistics2D
1695*/
1696template <class InputItX, class InputItY>
1697inline JKQTPColumnContourPlot* jkqtpstatAddKDE2DContour(JKQTBasePlotter* plotter, InputItX firstX, InputItX lastX, InputItY firstY, InputItY lastY, size_t xbins=10, size_t ybins=10, const std::function<double(double,double)>& kernel=std::function<double(double,double)>(&jkqtpstatKernel2DGaussian), double bandwidthX=1.0, double bandwidthY=1.0, const QString& kdecolumnBaseName=QString("histogram"), double* oxmin=nullptr, double* oxmax=nullptr, double* oymin=nullptr, double* oymax=nullptr) {
1698 double xmin=0, xmax=0;
1699 double ymin=0, ymax=0;
1700 jkqtpstatMinMax(firstX,lastX, xmin,xmax);
1701 jkqtpstatMinMax(firstY,lastY, ymin,ymax);
1702 size_t histcol=plotter->getDatastore()->addImageColumn(xbins, ybins, kdecolumnBaseName);
1703 jkqtpstatKDE2D(firstX,lastX,firstY,lastY,
1704 plotter->getDatastore()->begin(histcol),
1705 xmin, xmax, ymin, ymax,
1706 xbins, ybins, kernel, bandwidthX, bandwidthY);
1708 plotter->addGraph(gHist=new JKQTPColumnContourPlot(plotter));
1709 gHist->setImageColumn(static_cast<int>(histcol));
1710 gHist->setX(xmin);
1711 gHist->setY(ymin);
1712 gHist->setWidth(xmax-xmin);
1713 gHist->setHeight(ymax-ymin);
1714 gHist->setTitle(QObject::tr("2D KDE"));
1715 gHist->createContourLevels(5);
1716 if (oxmax) *oxmax=xmax;
1717 if (oxmin) *oxmin=xmin;
1718 if (oymax) *oymax=ymax;
1719 if (oymin) *oymin=ymin;
1720 return gHist;
1721}
1722
1723
1724
1725
1726
1727
1728
1729/*! \brief calculate the linear regression coefficients for a given data range \a firstX / \a firstY ... \a lastX / \a lastY where the model is \f$ f(x)=a+b\cdot x \f$
1730 \ingroup jkqtptools_math_statistics_adaptors
1731
1732 \tparam InputItX standard iterator type of \a firstX and \a lastX.
1733 \tparam InputItY standard iterator type of \a firstY and \a lastY.
1734 \param plotter the plotter to which to add the resulting graph
1735 \param firstX iterator pointing to the first item in the x-dataset to use \f$ x_1 \f$
1736 \param lastX iterator pointing behind the last item in the x-dataset to use \f$ x_N \f$
1737 \param firstY iterator pointing to the first item in the y-dataset to use \f$ y_1 \f$
1738 \param lastY iterator pointing behind the last item in the y-dataset to use \f$ y_N \f$
1739 \param[in,out] coeffA returns the offset of the linear model
1740 \param[in,out] coeffB returns the slope of the linear model
1741 \param fixA if \c true, the offset coefficient \f$ a \f$ is not determined by the fit, but the value provided in \a coeffA is used \note If \a fixA \c ==true, You need to provide a value for A in \a coeffA
1742 \param fixB if \c true, the slope coefficient \f$ b \f$ is not determined by the fit, but the value provided in \a coeffB is used \note If \a fixB \c ==true, You need to provide a value for B in \a coeffB
1743
1744 Example:
1745 \code
1746 jkqtpstatAddLinearRegression(plot1->getPlotter(), datastore1->begin(colLinX), datastore1->end(colLinX), datastore1->begin(colLinY), datastore1->end(colLinY));
1747 \endcode
1748
1749 \image html datastore_regression_lin.png
1750
1751 \see \ref JKQTPlotterBasicJKQTPDatastoreRegression, jkqtpstatLinearRegression()
1752*/
1753template <class InputItX, class InputItY>
1754inline JKQTPXFunctionLineGraph* jkqtpstatAddLinearRegression(JKQTBasePlotter* plotter, InputItX firstX, InputItX lastX, InputItY firstY, InputItY lastY, double* coeffA=nullptr, double* coeffB=nullptr, bool fixA=false, bool fixB=false) {
1755 double cA=0;
1756 if (coeffA) cA=*coeffA;
1757 double cB=0;
1758 if (coeffB) cB=*coeffB;
1759
1760 JKQTPASSERT_M(!fixA || (fixA && coeffA!=nullptr), "if fixA=true, coeffA needs to be provided");
1761 JKQTPASSERT_M(!fixB || (fixB && coeffB!=nullptr), "if fixB=true, coeffB needs to be provided");
1762
1763 jkqtpstatLinearRegression(firstX, lastX, firstY, lastY, cA, cB, fixA, fixB);
1766 g->setParamsV(cA, cB);
1767 g->setTitle(QString("regression: $f(x) = %1%2{\\cdot}x, \\chi^2=%4, R^2=%3$").arg(jkqtp_floattolatexqstr(cA, 2, true, 1e-16,1e-2, 1e4,false)).arg(jkqtp_floattolatexqstr(cB, 2, true, 1e-16,1e-2, 1e4,true)).arg(jkqtp_floattolatexqstr(jkqtpstatCoefficientOfDetermination(firstX,lastX,firstY,lastY,jkqtpStatGenerateRegressionModel(JKQTPStatRegressionModelType::Linear, cA, cB)),3)).arg(jkqtp_floattolatexqstr(jkqtpstatSumOfDeviations(firstX,lastX,firstY,lastY,jkqtpStatGenerateRegressionModel(JKQTPStatRegressionModelType::Linear, cA, cB)),3)));
1768 plotter->addGraph(g);
1769 if (coeffA) *coeffA=cA;
1770 if (coeffB) *coeffB=cB;
1771 return g;
1772}
1773
1774
1775/*! \brief calculate the linear regression coefficients for a given data data used to draw any `JKQTPXYGraph` \a datagraph where the model is \f$ f(x)=a+b\cdot x \f$
1776 \ingroup jkqtptools_math_statistics_adaptors
1777
1778 \param datagraph graph representing the (x,y) datapairs to which to fit the regression line
1779 \param[in,out] coeffA returns the offset of the linear model
1780 \param[in,out] coeffB returns the slope of the linear model
1781 \param fixA if \c true, the offset coefficient \f$ a \f$ is not determined by the fit, but the value provided in \a coeffA is used \note If \a fixA \c ==true, You need to provide a value for A in \a coeffA
1782 \param fixB if \c true, the slope coefficient \f$ b \f$ is not determined by the fit, but the value provided in \a coeffB is used \note If \a fixB \c ==true, You need to provide a value for B in \a coeffB
1783
1784 Example:
1785 \code
1786 JKQTPXYLineGraph* graphD;
1787 plot1->addGraph(graphD=new JKQTPXYLineGraph(plot1));
1788 graphD->setXYColumns(colLinX, colLinY);
1789 jkqtpstatAddLinearRegression(graphD);
1790 \endcode
1791
1792 \image html datastore_regression_lin.png
1793
1794 \note The line graph is added to the same plotter that is the parent of \a datagraph !
1795
1796 \see \ref JKQTPlotterBasicJKQTPDatastoreRegression, jkqtpstatLinearRegression()
1797*/
1798JKQTPLOTTER_LIB_EXPORT JKQTPXFunctionLineGraph* jkqtpstatAddLinearRegression(JKQTPXYGraph *datagraph, double* coeffA=nullptr, double* coeffB=nullptr, bool fixA=false, bool fixB=false);
1799
1800
1801
1802/*! \brief calculate the (robust) iteratively reweighted least-squares (IRLS) estimate for the parameters of the model \f$ f(x)=a+b\cdot x \f$
1803 for a given data range \a firstX / \a firstY ... \a lastX / \a lastY
1804 \ingroup jkqtptools_math_statistics_adaptors
1805
1806 \tparam InputItX standard iterator type of \a firstX and \a lastX.
1807 \tparam InputItY standard iterator type of \a firstY and \a lastY.
1808 \param plotter the plotter to which to add the resulting graph
1809 \param firstX iterator pointing to the first item in the x-dataset to use \f$ x_1 \f$
1810 \param lastX iterator pointing behind the last item in the x-dataset to use \f$ x_N \f$
1811 \param firstY iterator pointing to the first item in the y-dataset to use \f$ y_1 \f$
1812 \param lastY iterator pointing behind the last item in the y-dataset to use \f$ y_N \f$
1813 \param[in,out] coeffA returns the offset of the linear model
1814 \param[in,out] coeffB returns the slope of the linear model
1815 \param fixA if \c true, the offset coefficient \f$ a \f$ is not determined by the fit, but the value provided in \a coeffA is used \note If \a fixA \c ==true, You need to provide a value for A in \a coeffA
1816 \param fixB if \c true, the slope coefficient \f$ b \f$ is not determined by the fit, but the value provided in \a coeffB is used \note If \a fixB \c ==true, You need to provide a value for B in \a coeffB
1817 \param p regularization parameter, the optimization problem is formulated in the \f$ L_p \f$ norm, using this \a p (see image below for an example)
1818 \param iterations the number of iterations the IRLS algorithm performs
1819
1820 Example:
1821 \code
1822 jkqtpstatAddRobustIRLSLinearRegression(plot1->getPlotter(), datastore1->begin(colLinX), datastore1->end(colLinX), datastore1->begin(colLinY), datastore1->end(colLinY));
1823 \endcode
1824
1825 \image html datastore_regression_linrobust.png
1826
1827 \see \ref JKQTPlotterBasicJKQTPDatastoreRegression, jkqtpstatRobustIRLSLinearRegression()
1828*/
1829template <class InputItX, class InputItY>
1830inline JKQTPXFunctionLineGraph* jkqtpstatAddRobustIRLSLinearRegression(JKQTBasePlotter* plotter, InputItX firstX, InputItX lastX, InputItY firstY, InputItY lastY, double* coeffA=nullptr, double* coeffB=nullptr, bool fixA=false, bool fixB=false, double p=1.1, int iterations=100) {
1831 double cA=0;
1832 if (coeffA) cA=*coeffA;
1833 double cB=0;
1834 if (coeffB) cB=*coeffB;
1835
1836 JKQTPASSERT_M(!fixA || (fixA && coeffA!=nullptr), "if fixA=true, coeffA needs to be provided");
1837 JKQTPASSERT_M(!fixB || (fixB && coeffB!=nullptr), "if fixB=true, coeffB needs to be provided");
1838
1839 jkqtpstatRobustIRLSLinearRegression(firstX, lastX, firstY, lastY, cA, cB, fixA, fixB, p, iterations);
1842 g->setParamsV(cA, cB);
1843 g->setTitle(QString("robust regression: $f(x) = %1%2{\\cdot}x, \\chi^2=%4, R^2=%3$").arg(jkqtp_floattolatexqstr(cA, 2, true, 1e-16,1e-2, 1e4,false)).arg(jkqtp_floattolatexqstr(cB, 2, true, 1e-16,1e-2, 1e4,true)).arg(jkqtp_floattolatexqstr(jkqtpstatCoefficientOfDetermination(firstX,lastX,firstY,lastY,jkqtpStatGenerateRegressionModel(JKQTPStatRegressionModelType::Linear, cA, cB)),3)).arg(jkqtp_floattolatexqstr(jkqtpstatSumOfDeviations(firstX,lastX,firstY,lastY,jkqtpStatGenerateRegressionModel(JKQTPStatRegressionModelType::Linear, cA, cB)),3)));
1844 plotter->addGraph(g);
1845 if (coeffA) *coeffA=cA;
1846 if (coeffB) *coeffB=cB;
1847 return g;
1848}
1849
1850
1851/*! \brief calculate the (robust) iteratively reweighted least-squares (IRLS) estimate for the parameters of the model \f$ f(x)=a+b\cdot x \f$
1852 for a given data range \a firstX / \a firstY ... \a lastX / \a lastY
1853 \ingroup jkqtptools_math_statistics_adaptors
1854
1855 \param datagraph graph representing the (x,y) datapairs to which to fit the regression line
1856 \param[in,out] coeffA returns the offset of the linear model
1857 \param[in,out] coeffB returns the slope of the linear model
1858 \param fixA if \c true, the offset coefficient \f$ a \f$ is not determined by the fit, but the value provided in \a coeffA is used \note If \a fixA \c ==true, You need to provide a value for A in \a coeffA
1859 \param fixB if \c true, the slope coefficient \f$ b \f$ is not determined by the fit, but the value provided in \a coeffB is used \note If \a fixB \c ==true, You need to provide a value for B in \a coeffB
1860 \param p regularization parameter, the optimization problem is formulated in the \f$ L_p \f$ norm, using this \a p (see image below for an example)
1861 \param iterations the number of iterations the IRLS algorithm performs
1862
1863 Example:
1864 \code
1865 JKQTPXYLineGraph* graphD;
1866 plot1->addGraph(graphD=new JKQTPXYLineGraph(plot1));
1867 graphD->setXYColumns(colLinX, colLinY);
1868 jkqtpstatAddRobustIRLSLinearRegression(graphD);
1869 \endcode
1870
1871 \image html datastore_regression_linrobust.png
1872
1873 \note The line graph is added to the same plotter that is the parent of \a datagraph !
1874
1875 \see \ref JKQTPlotterBasicJKQTPDatastoreRegression, jkqtpstatRobustIRLSLinearRegression()
1876*/
1877JKQTPLOTTER_LIB_EXPORT JKQTPXFunctionLineGraph *jkqtpstatAddRobustIRLSLinearRegression(JKQTPXYGraph *datagraph, double* coeffA=nullptr, double* coeffB=nullptr, bool fixA=false, bool fixB=false, double p=1.1, int iterations=100);
1878
1879
1880
1881/*! \brief calculate the weighted linear regression coefficients for a given for a given data range \a firstX / \a firstY / \a firstW ... \a lastX / \a lastY / \a lastW where the model is \f$ f(x)=a+b\cdot x \f$
1882 \ingroup jkqtptools_math_statistics_adaptors
1883
1884 \tparam InputItX standard iterator type of \a firstX and \a lastX.
1885 \tparam InputItY standard iterator type of \a firstY and \a lastY.
1886 \tparam InputItW standard iterator type of \a firstW and \a lastW.
1887 \param plotter the plotter to which to add the resulting graph
1888 \param firstX iterator pointing to the first item in the x-dataset to use \f$ x_1 \f$
1889 \param lastX iterator pointing behind the last item in the x-dataset to use \f$ x_N \f$
1890 \param firstY iterator pointing to the first item in the y-dataset to use \f$ y_1 \f$
1891 \param lastY iterator pointing behind the last item in the y-dataset to use \f$ y_N \f$
1892 \param firstW iterator pointing to the first item in the weight-dataset to use \f$ w_1 \f$
1893 \param lastW iterator pointing behind the last item in the weight-dataset to use \f$ w_N \f$
1894 \param[in,out] coeffA returns the offset of the linear model
1895 \param[in,out] coeffB returns the slope of the linear model
1896 \param fixA if \c true, the offset coefficient \f$ a \f$ is not determined by the fit, but the value provided in \a coeffA is used \note If \a fixA \c ==true, You need to provide a value for A in \a coeffA
1897 \param fixB if \c true, the slope coefficient \f$ b \f$ is not determined by the fit, but the value provided in \a coeffB is used \note If \a fixB \c ==true, You need to provide a value for B in \a coeffB
1898 \param fWeightDataToWi an optional function, which is applied to the data from \a firstW ... \a lastW to convert them to weight, i.e. \c wi=fWeightDataToWi(*itW)
1899 e.g. if you use data used to draw error bars, you can use jkqtp_inversePropSaveDefault(). The default is jkqtp_identity(), which just returns the values.
1900 In the case of jkqtp_inversePropSaveDefault(), a datapoint x,y, has a large weight, if it's error is small and in the case if jkqtp_identity() it's weight
1901 is directly proportional to the given value.
1902
1903 Example:
1904 \code
1905 double coeffA=0, coeffB=0;
1906 jkqtpstatLinearWeightedRegression(datastore1->begin(colWLinX), datastore1->end(colWLinX),
1907 datastore1->begin(colWLinY), datastore1->end(colWLinY),
1908 datastore1->begin(colWLinE), datastore1->end(colWLinE),
1909 coeffA, coeffB, false, false,
1910 &jkqtp_inversePropSaveDefault<double>);
1911 \endcode
1912
1913 \image html datastore_regression_linweight.png
1914
1915 \see \ref JKQTPlotterBasicJKQTPDatastoreRegression, jkqtpstatLinearRegression()
1916*/
1917template <class InputItX, class InputItY, class InputItW>
1918inline JKQTPXFunctionLineGraph* jkqtpstatAddLinearWeightedRegression(JKQTBasePlotter* plotter, InputItX firstX, InputItX lastX, InputItY firstY, InputItY lastY, InputItW firstW, InputItW lastW, double* coeffA=nullptr, double* coeffB=nullptr, bool fixA=false, bool fixB=false, std::function<double(double)> fWeightDataToWi=&jkqtp_identity<double>) {
1919 double cA=0;
1920 if (coeffA) cA=*coeffA;
1921 double cB=0;
1922 if (coeffB) cB=*coeffB;
1923
1924 JKQTPASSERT_M(!fixA || (fixA && coeffA!=nullptr), "if fixA=true, coeffA needs to be provided");
1925 JKQTPASSERT_M(!fixB || (fixB && coeffB!=nullptr), "if fixB=true, coeffB needs to be provided");
1926
1927 jkqtpstatLinearWeightedRegression(firstX, lastX, firstY, lastY, firstW, lastW, cA, cB, fixA, fixB, fWeightDataToWi);
1930 g->setParamsV(cA, cB);
1931 g->setTitle(QString("weighted regression: $f(x) = %1%2{\\cdot}x, \\chi^2=%4, R^2=%3$").arg(jkqtp_floattolatexqstr(cA, 2, true, 1e-16,1e-2, 1e4,false)).arg(jkqtp_floattolatexqstr(cB, 2, true, 1e-16,1e-2, 1e4,true)).arg(jkqtp_floattolatexqstr(jkqtpstatWeightedCoefficientOfDetermination(firstX,lastX,firstY,lastY,firstW,lastW,jkqtpStatGenerateRegressionModel(JKQTPStatRegressionModelType::Linear, cA, cB),fWeightDataToWi),3)).arg(jkqtp_floattolatexqstr(jkqtpstatWeightedSumOfDeviations(firstX,lastX,firstY,lastY,firstW,lastW,jkqtpStatGenerateRegressionModel(JKQTPStatRegressionModelType::Linear, cA, cB),fWeightDataToWi),3)));
1932 plotter->addGraph(g);
1933 if (coeffA) *coeffA=cA;
1934 if (coeffB) *coeffB=cB;
1935 return g;
1936}
1937
1938/*! \brief calculate the linear weighted regression coefficients for a given data data used to draw any `JKQTPXYGraph` \a datagraph , which also implements JKQTPYGraphErrorData and where the model is \f$ f(x)=a+b\cdot x \f$
1939 \ingroup jkqtptools_math_statistics_adaptors
1940
1941 \param datagraph graph representing the (x,y,error) data triples to which to fit the regression line
1942 The errors are used as iverse weights!
1943 \param[in,out] coeffA returns the offset of the linear model
1944 \param[in,out] coeffB returns the slope of the linear model
1945 \param fixA if \c true, the offset coefficient \f$ a \f$ is not determined by the fit, but the value provided in \a coeffA is used \note If \a fixA \c ==true, You need to provide a value for A in \a coeffA
1946 \param fixB if \c true, the slope coefficient \f$ b \f$ is not determined by the fit, but the value provided in \a coeffB is used \note If \a fixB \c ==true, You need to provide a value for B in \a coeffB
1947
1948 Example:
1949 \code
1950 JKQTPXYLineErrorGraph* graphD;
1951 plot1->addGraph(graphD=new JKQTPXYLineErrorGraph(plot1));
1952 graphD->setXYColumns(colLinX, colLinY);
1953 graphD->setYErrorColumn(static_cast<int>(colWLinE));
1954 jkqtpstatAddLinearWeightedRegression(graphD);
1955 \endcode
1956
1957 \image html datastore_regression_linweight.png
1958
1959 \note The line graph is added to the same plotter that is the parent of \a datagraph !
1960
1961 \see \ref JKQTPlotterBasicJKQTPDatastoreRegression, jkqtpstatLinearRegression()
1962*/
1963JKQTPLOTTER_LIB_EXPORT JKQTPXFunctionLineGraph* jkqtpstatAddLinearWeightedRegression(JKQTPXYGraph *datagraph, double* coeffA=nullptr, double* coeffB=nullptr, bool fixA=false, bool fixB=false);
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978/*! \brief calculate the linear regression coefficients for a given data range \a firstX / \a firstY ... \a lastX / \a lastY where the model is defined by \a type
1979 \ingroup jkqtptools_math_statistics_adaptors
1980
1981 \tparam InputItX standard iterator type of \a firstX and \a lastX.
1982 \tparam InputItY standard iterator type of \a firstY and \a lastY.
1983 \param plotter the plotter to which to add the resulting graph
1984 \param type model to be fitted
1985 \param firstX iterator pointing to the first item in the x-dataset to use \f$ x_1 \f$
1986 \param lastX iterator pointing behind the last item in the x-dataset to use \f$ x_N \f$
1987 \param firstY iterator pointing to the first item in the y-dataset to use \f$ y_1 \f$
1988 \param lastY iterator pointing behind the last item in the y-dataset to use \f$ y_N \f$
1989 \param[in,out] coeffA returns the offset of the linear model
1990 \param[in,out] coeffB returns the slope of the linear model
1991 \param fixA if \c true, the offset coefficient \f$ a \f$ is not determined by the fit, but the value provided in \a coeffA is used \note If \a fixA \c ==true, You need to provide a value for A in \a coeffA
1992 \param fixB if \c true, the slope coefficient \f$ b \f$ is not determined by the fit, but the value provided in \a coeffB is used \note If \a fixB \c ==true, You need to provide a value for B in \a coeffB
1993
1994 Example:
1995 \code
1996 jkqtpstatRegression(plot1->getPlotter(), JKQTPStatRegressionModelType::Exponential, datastore1->begin(colLinX), datastore1->end(colLinX), datastore1->begin(colLinY), datastore1->end(colLinY));
1997 \endcode
1998
1999 \image html datastore_regression_nonlinreg_exp.png
2000
2001 \see \ref JKQTPlotterBasicJKQTPDatastoreRegression, jkqtpstatRegression()
2002*/
2003template <class InputItX, class InputItY>
2004inline JKQTPXFunctionLineGraph* jkqtpstatAddRegression(JKQTBasePlotter* plotter, JKQTPStatRegressionModelType type, InputItX firstX, InputItX lastX, InputItY firstY, InputItY lastY, double* coeffA=nullptr, double* coeffB=nullptr, bool fixA=false, bool fixB=false) {
2005 double cA=0;
2006 if (coeffA) cA=*coeffA;
2007 double cB=0;
2008 if (coeffB) cB=*coeffB;
2009
2010 JKQTPASSERT_M(!fixA || (fixA && coeffA!=nullptr), "if fixA=true, coeffA needs to be provided");
2011 JKQTPASSERT_M(!fixB || (fixB && coeffB!=nullptr), "if fixB=true, coeffB needs to be provided");
2012
2013 jkqtpstatRegression(type, firstX, lastX, firstY, lastY, cA, cB, fixA, fixB);
2016 g->setTitle(QString("regression: $%1, \\chi^2=%3, R^2=%2$").arg(jkqtpstatRegressionModel2Latex(type, cA, cB)).arg(jkqtp_floattolatexqstr(jkqtpstatCoefficientOfDetermination(firstX,lastX,firstY,lastY,jkqtpStatGenerateRegressionModel(type, cA, cB)),3)).arg(jkqtp_floattolatexqstr(jkqtpstatSumOfDeviations(firstX,lastX,firstY,lastY,jkqtpStatGenerateRegressionModel(type, cA, cB)),3)));
2017 plotter->addGraph(g);
2018 if (coeffA) *coeffA=cA;
2019 if (coeffB) *coeffB=cB;
2020 return g;
2021}
2022
2023
2024/*! \brief calculate the linear regression coefficients for a given data data used to draw any `JKQTPXYGraph` \a datagraph where the model is defined by \a type
2025
2026 \param datagraph graph representing the (x,y) datapairs to which to fit the regression line
2027 \param type model to be fitted
2028 \param[in,out] coeffA returns the offset of the linear model
2029 \param[in,out] coeffB returns the slope of the linear model
2030 \param fixA if \c true, the offset coefficient \f$ a \f$ is not determined by the fit, but the value provided in \a coeffA is used \note If \a fixA \c ==true, You need to provide a value for A in \a coeffA
2031 \param fixB if \c true, the slope coefficient \f$ b \f$ is not determined by the fit, but the value provided in \a coeffB is used \note If \a fixB \c ==true, You need to provide a value for B in \a coeffB
2032
2033 Example:
2034 \code
2035 JKQTPXYLineGraph* graphD;
2036 plot1->addGraph(graphD=new JKQTPXYLineGraph(plot1));
2037 graphD->setXYColumns(colLinX, colLinY);
2038 jkqtpstatRegression(graphD, JKQTPStatRegressionModelType::Exponential);
2039 \endcode
2040
2041 \image html datastore_regression_nonlinreg_exp.png
2042
2043 \note The line graph is added to the same plotter that is the parent of \a datagraph !
2044
2045 \see \ref JKQTPlotterBasicJKQTPDatastoreRegression, jkqtpstatRegression()
2046*/
2047JKQTPLOTTER_LIB_EXPORT JKQTPXFunctionLineGraph* jkqtpstatAddRegression(JKQTPXYGraph *datagraph, JKQTPStatRegressionModelType type, double* coeffA=nullptr, double* coeffB=nullptr, bool fixA=false, bool fixB=false);
2048
2049
2050
2051/*! \brief calculate the (robust) iteratively reweighted least-squares (IRLS) estimate for the parameters where the model is defined by \a type
2052 for a given data range \a firstX / \a firstY ... \a lastX / \a lastY
2053 \ingroup jkqtptools_math_statistics_adaptors
2054
2055 \tparam InputItX standard iterator type of \a firstX and \a lastX.
2056 \tparam InputItY standard iterator type of \a firstY and \a lastY.
2057 \param plotter the plotter to which to add the resulting graph
2058 \param type model to be fitted
2059 \param firstX iterator pointing to the first item in the x-dataset to use \f$ x_1 \f$
2060 \param lastX iterator pointing behind the last item in the x-dataset to use \f$ x_N \f$
2061 \param firstY iterator pointing to the first item in the y-dataset to use \f$ y_1 \f$
2062 \param lastY iterator pointing behind the last item in the y-dataset to use \f$ y_N \f$
2063 \param[in,out] coeffA returns the offset of the linear model
2064 \param[in,out] coeffB returns the slope of the linear model
2065 \param fixA if \c true, the offset coefficient \f$ a \f$ is not determined by the fit, but the value provided in \a coeffA is used \note If \a fixA \c ==true, You need to provide a value for A in \a coeffA
2066 \param fixB if \c true, the slope coefficient \f$ b \f$ is not determined by the fit, but the value provided in \a coeffB is used \note If \a fixB \c ==true, You need to provide a value for B in \a coeffB
2067 \param p regularization parameter, the optimization problem is formulated in the \f$ L_p \f$ norm, using this \a p (see image below for an example)
2068 \param iterations the number of iterations the IRLS algorithm performs
2069
2070 Example:
2071 \code
2072 jkqtpstatAddRobustIRLSRegression(plot1->getPlotter(), JKQTPStatRegressionModelType::Exponential, datastore1->begin(colLinX), datastore1->end(colLinX), datastore1->begin(colLinY), datastore1->end(colLinY));
2073 \endcode
2074
2075 \image html datastore_regression_linrobust.png
2076
2077 \see \ref JKQTPlotterBasicJKQTPDatastoreRegression, jkqtpstatRobustIRLSRegression()
2078*/
2079template <class InputItX, class InputItY>
2080inline JKQTPXFunctionLineGraph* jkqtpstatAddRobustIRLSRegression(JKQTBasePlotter* plotter, JKQTPStatRegressionModelType type, InputItX firstX, InputItX lastX, InputItY firstY, InputItY lastY, double* coeffA=nullptr, double* coeffB=nullptr, bool fixA=false, bool fixB=false, double p=1.1, int iterations=100) {
2081 double cA=0;
2082 if (coeffA) cA=*coeffA;
2083 double cB=0;
2084 if (coeffB) cB=*coeffB;
2085
2086 JKQTPASSERT_M(!fixA || (fixA && coeffA!=nullptr), "if fixA=true, coeffA needs to be provided");
2087 JKQTPASSERT_M(!fixB || (fixB && coeffB!=nullptr), "if fixB=true, coeffB needs to be provided");
2088
2089 jkqtpstatRobustIRLSRegression(type, firstX, lastX, firstY, lastY, cA, cB, fixA, fixB, p, iterations);
2092 g->setTitle(QString("robust regression: $%1, \\chi^2=%3, R^2=%2$").arg(jkqtpstatRegressionModel2Latex(type, cA, cB)).arg(jkqtp_floattolatexqstr(jkqtpstatCoefficientOfDetermination(firstX,lastX,firstY,lastY,jkqtpStatGenerateRegressionModel(type, cA, cB)),3)).arg(jkqtp_floattolatexqstr(jkqtpstatSumOfDeviations(firstX,lastX,firstY,lastY,jkqtpStatGenerateRegressionModel(type, cA, cB)),3)));
2093 plotter->addGraph(g);
2094 if (coeffA) *coeffA=cA;
2095 if (coeffB) *coeffB=cB;
2096 return g;
2097}
2098
2099
2100/*! \brief calculate the (robust) iteratively reweighted least-squares (IRLS) estimate for the parameters where the model is defined by \a type
2101 for a given data range \a firstX / \a firstY ... \a lastX / \a lastY
2102 \ingroup jkqtptools_math_statistics_adaptors
2103
2104 \param datagraph graph representing the (x,y) datapairs to which to fit the regression line
2105 \param type model to be fitted
2106 \param[in,out] coeffA returns the offset of the linear model
2107 \param[in,out] coeffB returns the slope of the linear model
2108 \param fixA if \c true, the offset coefficient \f$ a \f$ is not determined by the fit, but the value provided in \a coeffA is used \note If \a fixA \c ==true, You need to provide a value for A in \a coeffA
2109 \param fixB if \c true, the slope coefficient \f$ b \f$ is not determined by the fit, but the value provided in \a coeffB is used \note If \a fixB \c ==true, You need to provide a value for B in \a coeffB
2110 \param p regularization parameter, the optimization problem is formulated in the \f$ L_p \f$ norm, using this \a p (see image below for an example)
2111 \param iterations the number of iterations the IRLS algorithm performs
2112
2113 Example:
2114 \code
2115 JKQTPXYLineGraph* graphD;
2116 plot1->addGraph(graphD=new JKQTPXYLineGraph(plot1));
2117 graphD->setXYColumns(colLinX, colLinY);
2118 jkqtpstatAddRobustIRLSRegression(graphD, JKQTPStatRegressionModelType::Exponential);
2119 \endcode
2120
2121 \image html datastore_regression_linrobust.png
2122
2123 \note The line graph is added to the same plotter that is the parent of \a datagraph !
2124
2125 \see \ref JKQTPlotterBasicJKQTPDatastoreRegression, jkqtpstatRobustIRLSRegression()
2126*/
2127JKQTPLOTTER_LIB_EXPORT JKQTPXFunctionLineGraph *jkqtpstatAddRobustIRLSRegression(JKQTPXYGraph *datagraph, JKQTPStatRegressionModelType type, double* coeffA=nullptr, double* coeffB=nullptr, bool fixA=false, bool fixB=false, double p=1.1, int iterations=100);
2128
2129
2130
2131/*! \brief calculate the weighted linear regression coefficients for a given for a given data range \a firstX / \a firstY / \a firstW ... \a lastX / \a lastY / \a lastW where the model is defined by \a type
2132 \ingroup jkqtptools_math_statistics_adaptors
2133
2134 \tparam InputItX standard iterator type of \a firstX and \a lastX.
2135 \tparam InputItY standard iterator type of \a firstY and \a lastY.
2136 \tparam InputItW standard iterator type of \a firstW and \a lastW.
2137 \param plotter the plotter to which to add the resulting graph
2138 \param type model to be fitted
2139 \param firstX iterator pointing to the first item in the x-dataset to use \f$ x_1 \f$
2140 \param lastX iterator pointing behind the last item in the x-dataset to use \f$ x_N \f$
2141 \param firstY iterator pointing to the first item in the y-dataset to use \f$ y_1 \f$
2142 \param lastY iterator pointing behind the last item in the y-dataset to use \f$ y_N \f$
2143 \param firstW iterator pointing to the first item in the weight-dataset to use \f$ w_1 \f$
2144 \param lastW iterator pointing behind the last item in the weight-dataset to use \f$ w_N \f$
2145 \param[in,out] coeffA returns the offset of the linear model
2146 \param[in,out] coeffB returns the slope of the linear model
2147 \param fixA if \c true, the offset coefficient \f$ a \f$ is not determined by the fit, but the value provided in \a coeffA is used \note If \a fixA \c ==true, You need to provide a value for A in \a coeffA
2148 \param fixB if \c true, the slope coefficient \f$ b \f$ is not determined by the fit, but the value provided in \a coeffB is used \note If \a fixB \c ==true, You need to provide a value for B in \a coeffB
2149 \param fWeightDataToWi an optional function, which is applied to the data from \a firstW ... \a lastW to convert them to weight, i.e. \c wi=fWeightDataToWi(*itW)
2150 e.g. if you use data used to draw error bars, you can use jkqtp_inversePropSaveDefault(). The default is jkqtp_identity(), which just returns the values.
2151 In the case of jkqtp_inversePropSaveDefault(), a datapoint x,y, has a large weight, if it's error is small and in the case if jkqtp_identity() it's weight
2152 is directly proportional to the given value.
2153
2154 Example:
2155 \code
2156 double coeffA=0, coeffB=0;
2157 jkqtpstatAddWeightedRegression(plotter, JKQTPStatRegressionModelType::Exponential,
2158 datastore1->begin(colWLinX), datastore1->end(colWLinX),
2159 datastore1->begin(colWLinY), datastore1->end(colWLinY),
2160 datastore1->begin(colWLinE), datastore1->end(colWLinE),
2161 coeffA, coeffB, false, false,
2162 &jkqtp_inversePropSaveDefault<double>);
2163 \endcode
2164
2165 \image html datastore_regression_linweight.png
2166
2167 \see \ref JKQTPlotterBasicJKQTPDatastoreRegression, jkqtpstatWeightedRegression()
2168*/
2169template <class InputItX, class InputItY, class InputItW>
2170inline JKQTPXFunctionLineGraph* jkqtpstatAddWeightedRegression(JKQTBasePlotter* plotter, JKQTPStatRegressionModelType type, InputItX firstX, InputItX lastX, InputItY firstY, InputItY lastY, InputItW firstW, InputItW lastW, double* coeffA=nullptr, double* coeffB=nullptr, bool fixA=false, bool fixB=false, std::function<double(double)> fWeightDataToWi=&jkqtp_identity<double>) {
2171 double cA=0;
2172 if (coeffA) cA=*coeffA;
2173 double cB=0;
2174 if (coeffB) cB=*coeffB;
2175
2176 JKQTPASSERT_M(!fixA || (fixA && coeffA!=nullptr), "if fixA=true, coeffA needs to be provided");
2177 JKQTPASSERT_M(!fixB || (fixB && coeffB!=nullptr), "if fixB=true, coeffB needs to be provided");
2178
2179 jkqtpstatWeightedRegression(type, firstX, lastX, firstY, lastY, firstW, lastW, cA, cB, fixA, fixB, fWeightDataToWi);
2182 g->setTitle(QString("weighted regression: $%1, \\chi^2=%3, R^2=%2$").arg(jkqtpstatRegressionModel2Latex(type, cA, cB)).arg(jkqtp_floattolatexqstr(jkqtpstatCoefficientOfDetermination(firstX,lastX,firstY,lastY,jkqtpStatGenerateRegressionModel(type, cA, cB)),3)).arg(jkqtp_floattolatexqstr(jkqtpstatSumOfDeviations(firstX,lastX,firstY,lastY,jkqtpStatGenerateRegressionModel(type, cA, cB)),3)));
2183 plotter->addGraph(g);
2184 if (coeffA) *coeffA=cA;
2185 if (coeffB) *coeffB=cB;
2186 return g;
2187}
2188
2189/*! \brief calculate the linear weighted regression coefficients for a given data data used to draw any `JKQTPXYGraph` \a datagraph , which also implements JKQTPYGraphErrorData and where the model is defined by \a type
2190 \ingroup jkqtptools_math_statistics_adaptors
2191
2192 \param datagraph graph representing the (x,y,error) data triples to which to fit the regression line
2193 The errors are used as iverse weights!
2194 \param type model to be fitted
2195 \param[in,out] coeffA returns the offset of the linear model
2196 \param[in,out] coeffB returns the slope of the linear model
2197 \param fixA if \c true, the offset coefficient \f$ a \f$ is not determined by the fit, but the value provided in \a coeffA is used \note If \a fixA \c ==true, You need to provide a value for A in \a coeffA
2198 \param fixB if \c true, the slope coefficient \f$ b \f$ is not determined by the fit, but the value provided in \a coeffB is used \note If \a fixB \c ==true, You need to provide a value for B in \a coeffB
2199
2200 Example:
2201 \code
2202 JKQTPXYLineErrorGraph* graphD;
2203 plot1->addGraph(graphD=new JKQTPXYLineErrorGraph(plot1));
2204 graphD->setXYColumns(colLinX, colLinY);
2205 graphD->setYErrorColumn(static_cast<int>(colWLinE));
2206 jkqtpstatAddWeightedRegression(graphD, JKQTPStatRegressionModelType::Exponential);
2207 \endcode
2208
2209 \image html datastore_regression_linweight.png
2210
2211 \note The line graph is added to the same plotter that is the parent of \a datagraph !
2212
2213 \see \ref JKQTPlotterBasicJKQTPDatastoreRegression, jkqtpstatWeightedRegression()
2214*/
2215JKQTPLOTTER_LIB_EXPORT JKQTPXFunctionLineGraph* jkqtpstatAddWeightedRegression(JKQTPXYGraph *datagraph, JKQTPStatRegressionModelType type, double* coeffA=nullptr, double* coeffB=nullptr, bool fixA=false, bool fixB=false);
2216
2217
2218
2219
2220
2221
2222
2223/*! \brief fits (in a least-squares sense) a polynomial \f$ f(x)=\sum\limits_{i=0}^Pp_ix^i \f$ of order P to a set of N data pairs \f$ (x_i,y_i) \f$ from a given data range \a firstX / \a firstY ... \a lastX / \a lastY
2224 \ingroup jkqtptools_math_statistics_adaptors
2225
2226 \tparam InputItX standard iterator type of \a firstX and \a lastX.
2227 \tparam InputItY standard iterator type of \a firstY and \a lastY.
2228 \tparam OutputItP output iterator for the polynomial coefficients
2229 \param plotter the plotter to which to add the resulting graph
2230 \param firstX iterator pointing to the first item in the x-dataset to use \f$ x_1 \f$
2231 \param lastX iterator pointing behind the last item in the x-dataset to use \f$ x_N \f$
2232 \param firstY iterator pointing to the first item in the y-dataset to use \f$ y_1 \f$
2233 \param lastY iterator pointing behind the last item in the y-dataset to use \f$ y_N \f$
2234 \param P degree of the polynomial (P>=N !!!)
2235 \param[out] firstRes Iterator (of type \a OutputItP ), which receives the (P+1)-entry vector with the polynomial coefficients \f$ p_i \f$
2236
2237 Example:
2238 \code
2239 std::vector<double> pFit;
2240 jkqtpstatAddPolyFit(plot1->getPlotter(), JKQTPStatRegressionModelType::Exponential, datastore1->begin(colLinX), datastore1->end(colLinX), datastore1->begin(colLinY), datastore1->end(colLinY), 3, std::back_inserter(pFit));
2241 \endcode
2242
2243 \image html datastore_regression_polynom.png
2244
2245 \see \ref JKQTPlotterBasicJKQTPDatastoreRegression, jkqtpstatPolyFit()
2246*/
2247template <class InputItX, class InputItY, class OutputItP>
2248inline JKQTPXFunctionLineGraph* jkqtpstatAddPolyFit(JKQTBasePlotter* plotter, InputItX firstX, InputItX lastX, InputItY firstY, InputItY lastY, size_t P, OutputItP firstRes) {
2249 std::vector<double> pFit;
2251 jkqtpstatPolyFit(firstX,lastX,firstY,lastY,P,std::back_inserter(pFit));
2252 gPoly->setPlotFunctionFunctor(jkqtp_generatePolynomialModel(pFit.begin(), pFit.end()));
2253 gPoly->setTitle(QString("regression: $%1, \\chi^2=%3, R^2=%2$").arg(jkqtp_polynomialModel2Latex(pFit.begin(), pFit.end())).arg(jkqtp_floattolatexqstr(jkqtpstatCoefficientOfDetermination(firstX,lastX,firstY,lastY,jkqtp_generatePolynomialModel(pFit.begin(), pFit.end())),3)).arg(jkqtp_floattolatexqstr(jkqtpstatSumOfDeviations(firstX,lastX,firstY,lastY,jkqtp_generatePolynomialModel(pFit.begin(), pFit.end())),3)));
2254 std::copy(pFit.begin(), pFit.end(), firstRes);
2255 plotter->addGraph(gPoly);
2256 return gPoly;
2257}
2258
2259
2260/*! \brief fits (in a least-squares sense) a polynomial \f$ f(x)=\sum\limits_{i=0}^Pp_ix^i \f$ of order P to a set of N data pairs \f$ (x_i,y_i) \f$ from a given data range \a firstX / \a firstY ... \a lastX / \a lastY
2261 \ingroup jkqtptools_math_statistics_adaptors
2262
2263 \tparam InputItX standard iterator type of \a firstX and \a lastX.
2264 \tparam InputItY standard iterator type of \a firstY and \a lastY.
2265 \param plotter the plotter to which to add the resulting graph
2266 \param firstX iterator pointing to the first item in the x-dataset to use \f$ x_1 \f$
2267 \param lastX iterator pointing behind the last item in the x-dataset to use \f$ x_N \f$
2268 \param firstY iterator pointing to the first item in the y-dataset to use \f$ y_1 \f$
2269 \param lastY iterator pointing behind the last item in the y-dataset to use \f$ y_N \f$
2270 \param P degree of the polynomial (P>=N !!!)
2271
2272 Example:
2273 \code
2274 jkqtpstatAddPolyFit(plot1->getPlotter(), JKQTPStatRegressionModelType::Exponential, datastore1->begin(colLinX), datastore1->end(colLinX), datastore1->begin(colLinY), datastore1->end(colLinY), 3);
2275 \endcode
2276
2277 \image html datastore_regression_polynom.png
2278
2279 \see \ref JKQTPlotterBasicJKQTPDatastoreRegression, jkqtpstatPolyFit()
2280*/
2281template <class InputItX, class InputItY>
2282inline JKQTPXFunctionLineGraph* jkqtpstatAddPolyFit(JKQTBasePlotter* plotter, InputItX firstX, InputItX lastX, InputItY firstY, InputItY lastY, size_t P) {
2283 std::vector<double> pFit;
2284 return jkqtpstatAddPolyFit(plotter, firstX,lastX,firstY,lastY,P,std::back_inserter(pFit));
2285}
2286
2287
2288/*! \brief fits (in a least-squares sense) a polynomial \f$ f(x)=\sum\limits_{i=0}^Pp_ix^i \f$ of order P to a set of N data pairs \f$ (x_i,y_i) \f$ from a given JKQTPXYGraph \a datagraph
2289 \ingroup jkqtptools_math_statistics_adaptors
2290
2291 \tparam OutputItP output iterator for the polynomial coefficients
2292 \param datagraph graph representing the (x,y) datapairs to which to fit the regression line
2293 \param P degree of the polynomial (P>=N !!!)
2294 \param[out] firstRes Iterator (of type \a OutputItP ), which receives the (P+1)-entry vector with the polynomial coefficients \f$ p_i \f$
2295
2296 Example:
2297 \code
2298 JKQTPXYLineGraph* graphD;
2299 plot1->addGraph(graphD=new JKQTPXYLineGraph(plot1));
2300 graphD->setXYColumns(colLinX, colLinY);
2301 std::vector<double> pFit;
2302 jkqtpstatAddPolyFit(graphD, 3,std::back_inserter(pFit));
2303 \endcode
2304
2305 \image html datastore_regression_polynom.png
2306
2307 \see \ref JKQTPlotterBasicJKQTPDatastoreRegression, jkqtpstatPolyFit()
2308*/
2309template <class OutputItP>
2310inline JKQTPXFunctionLineGraph* jkqtpstatAddPolyFit(JKQTPXYGraph *datagraph, size_t P, OutputItP firstRes) {
2311 JKQTBasePlotter* plt=datagraph->getParent();
2312 JKQTPDatastore* ds=plt->getDatastore();
2313 return jkqtpstatAddPolyFit(plt, ds->begin(datagraph->getXColumn()), ds->end(datagraph->getXColumn()), ds->begin(datagraph->getYColumn()), ds->end(datagraph->getYColumn()),P,firstRes);
2314}
2315
2316
2317
2318/*! \brief fits (in a least-squares sense) a polynomial \f$ f(x)=\sum\limits_{i=0}^Pp_ix^i \f$ of order P to a set of N data pairs \f$ (x_i,y_i) \f$ from a given JKQTPXYGraph \a datagraph
2319 \ingroup jkqtptools_math_statistics_adaptors
2320
2321 \param datagraph graph representing the (x,y) datapairs to which to fit the regression line
2322 \param P degree of the polynomial (P>=N !!!)
2323
2324 Example:
2325 \code
2326 JKQTPXYLineGraph* graphD;
2327 plot1->addGraph(graphD=new JKQTPXYLineGraph(plot1));
2328 graphD->setXYColumns(colLinX, colLinY);
2329 jkqtpstatAddPolyFit(graphD, 3);
2330 \endcode
2331
2332 \image html datastore_regression_polynom.png
2333
2334 \see \ref JKQTPlotterBasicJKQTPDatastoreRegression, jkqtpstatPolyFit()
2335*/
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347/*! \brief create a plot with y-direction error bars, calculated from average +/- stddev of groups in the input data
2348 \ingroup jkqtptools_math_statistics_adaptors
2349
2350 \tparam TGraph type of graph that should be added to the plot
2351 \tparam InputCatIt standard iterator type of \a inFirstCat_X and \a inLastCat_X
2352 \tparam InputValueIt standard iterator type of \a inFirstValue_Y and \a inLastValue_Y
2353 \param plotter the plotter to which to add the resulting graph
2354 \param inFirstCat_X iterator pointing to the first item in the category dataset to use \f$ c_1 \f$ (used for x-coordinates)
2355 \param inLastCat_X iterator pointing behind the last item in the category dataset to use \f$ c_N \f$ (used for x-coordinates)
2356 \param inFirstValue_Y iterator pointing to the first item in the category dataset to use \f$ v_1 \f$ (used for y-coordinates)
2357 \param inLastValue_Y iterator pointing behind the last item in the category dataset to use \f$ v_N \f$ (used for y-coordinates)
2358 \param groupDefFunc assigns a group \f$ c_{\text{out},j} \f$ to each category value \f$ c_i \f$ .
2359 \param columnBaseName string component used to build the names of the columns generated by this function
2360 \return the graph showing \f$ c_{\text{out},j} \f$ and average +/- stddev for each group \f$ j \f$
2361
2362
2363
2364 \see jkqtpstatGroupData(), \ref JKQTPlotterBasicJKQTPDatastoreStatisticsGroupedStat
2365*/
2366template <class InputCatIt, class InputValueIt, class TGraph>
2367inline TGraph* jkqtpstatAddYErrorGraph(JKQTBasePlotter* plotter, InputCatIt inFirstCat_X, InputCatIt inLastCat_X, InputValueIt inFirstValue_Y, InputValueIt inLastValue_Y, JKQTPStatGroupDefinitionFunctor1D groupDefFunc=&jkqtpstatGroupingIdentity1D, const QString& columnBaseName=QString("grouped data")) {
2368 std::map<double, std::vector<double> > groupeddataBar;
2369 jkqtpstatGroupData(inFirstCat_X, inLastCat_X, inFirstValue_Y, inLastValue_Y, groupeddataBar, groupDefFunc);
2370
2371 size_t colGroup=plotter->getDatastore()->addColumn(columnBaseName+", group");
2372 size_t colAverage=plotter->getDatastore()->addColumn(columnBaseName+", average");
2373 size_t colStdDev=plotter->getDatastore()->addColumn(columnBaseName+", stddev");
2374
2375 for (auto it=groupeddataBar.begin(); it!=groupeddataBar.end(); ++it) {
2376 plotter->getDatastore()->appendToColumn(colGroup, it->first);
2377 plotter->getDatastore()->appendToColumn(colAverage, jkqtpstatAverage(it->second.begin(), it->second.end()));
2378 plotter->getDatastore()->appendToColumn(colStdDev, jkqtpstatStdDev(it->second.begin(), it->second.end()));
2379 }
2380
2381 // 2.4. Finally the calculated groups are drawn
2382 TGraph* graph;
2383 plotter->addGraph(graph=new TGraph(plotter));
2384 graph->setXColumn(colGroup);
2385 graph->setYColumn(colAverage);
2386 graph->setYErrorColumn(static_cast<int>(colStdDev));
2387
2388 return graph;
2389}
2390
2391
2392/*! \brief create a \c JKQTPXYLineErrorGraph with y-direction error bars, calculated from average +/- stddev of groups in the input data
2393 \ingroup jkqtptools_math_statistics_adaptors
2394
2395 \tparam InputCatIt standard iterator type of \a inFirstCat_X and \a inLastCat_X
2396 \tparam InputValueIt standard iterator type of \a inFirstValue_Y and \a inLastValue_Y
2397 \param plotter the plotter to which to add the resulting graph
2398 \param inFirstCat_X iterator pointing to the first item in the category dataset to use \f$ c_1 \f$ (used for x-coordinates)
2399 \param inLastCat_X iterator pointing behind the last item in the category dataset to use \f$ c_N \f$ (used for x-coordinates)
2400 \param inFirstValue_Y iterator pointing to the first item in the category dataset to use \f$ v_1 \f$ (used for y-coordinates)
2401 \param inLastValue_Y iterator pointing behind the last item in the category dataset to use \f$ v_N \f$ (used for y-coordinates)
2402 \param groupDefFunc assigns a group \f$ c_{\text{out},j} \f$ to each category value \f$ c_i \f$ .
2403 \param columnBaseName string component used to build the names of the columns generated by this function
2404 \return the graph showing \f$ c_{\text{out},j} \f$ and average +/- stddev for each group \f$ j \f$
2405
2406
2407
2408 \see jkqtpstatGroupData(), jkqtpstatAddYErrorGraph(), JKQTPXYLineErrorGraph, \ref JKQTPlotterBasicJKQTPDatastoreStatisticsGroupedStat
2409*/
2410template <class InputCatIt, class InputValueIt>
2411inline JKQTPXYLineErrorGraph* jkqtpstatAddYErrorLineGraph(JKQTBasePlotter* plotter, InputCatIt inFirstCat_X, InputCatIt inLastCat_X, InputValueIt inFirstValue_Y, InputValueIt inLastValue_Y, JKQTPStatGroupDefinitionFunctor1D groupDefFunc=&jkqtpstatGroupingIdentity1D, const QString& columnBaseName=QString("grouped data")) {
2412 return jkqtpstatAddYErrorGraph<InputCatIt,InputValueIt,JKQTPXYLineErrorGraph>(plotter,inFirstCat_X, inLastCat_X, inFirstValue_Y, inLastValue_Y, groupDefFunc, columnBaseName);
2413}
2414
2415
2416/*! \brief create a \c JKQTPBarVerticalErrorGraph with y-direction error bars, calculated from average +/- stddev of groups in the input data
2417 \ingroup jkqtptools_math_statistics_adaptors
2418
2419 \tparam InputCatIt standard iterator type of \a inFirstCat_X and \a inLastCat_X
2420 \tparam InputValueIt standard iterator type of \a inFirstValue_Y and \a inLastValue_Y
2421 \param plotter the plotter to which to add the resulting graph
2422 \param inFirstCat_X iterator pointing to the first item in the category dataset to use \f$ c_1 \f$ (used for x-coordinates)
2423 \param inLastCat_X iterator pointing behind the last item in the category dataset to use \f$ c_N \f$ (used for x-coordinates)
2424 \param inFirstValue_Y iterator pointing to the first item in the category dataset to use \f$ v_1 \f$ (used for y-coordinates)
2425 \param inLastValue_Y iterator pointing behind the last item in the category dataset to use \f$ v_N \f$ (used for y-coordinates)
2426 \param groupDefFunc assigns a group \f$ c_{\text{out},j} \f$ to each category value \f$ c_i \f$ .
2427 \param columnBaseName string component used to build the names of the columns generated by this function
2428 \return the graph showing \f$ c_{\text{out},j} \f$ and average +/- stddev for each group \f$ j \f$
2429
2430
2431
2432 \see jkqtpstatGroupData(), jkqtpstatAddYErrorGraph(), JKQTPBarVerticalErrorGraph, \ref JKQTPlotterBasicJKQTPDatastoreStatisticsGroupedStat
2433*/
2434template <class InputCatIt, class InputValueIt>
2435inline JKQTPBarVerticalErrorGraph* jkqtpstatAddYErrorBarGraph(JKQTBasePlotter* plotter, InputCatIt inFirstCat_X, InputCatIt inLastCat_X, InputValueIt inFirstValue_Y, InputValueIt inLastValue_Y, JKQTPStatGroupDefinitionFunctor1D groupDefFunc=&jkqtpstatGroupingIdentity1D, const QString& columnBaseName=QString("grouped data")) {
2436 return jkqtpstatAddYErrorGraph<InputCatIt,InputValueIt,JKQTPBarVerticalErrorGraph>(plotter,inFirstCat_X, inLastCat_X, inFirstValue_Y, inLastValue_Y, groupDefFunc, columnBaseName);
2437}
2438
2439
2440/*! \brief create a \c JKQTPImpulsesVerticalErrorGraph with y-direction error bars, calculated from average +/- stddev of groups in the input data
2441 \ingroup jkqtptools_math_statistics_adaptors
2442
2443 \tparam InputCatIt standard iterator type of \a inFirstCat_X and \a inLastCat_X
2444 \tparam InputValueIt standard iterator type of \a inFirstValue_Y and \a inLastValue_Y
2445 \param plotter the plotter to which to add the resulting graph
2446 \param inFirstCat_X iterator pointing to the first item in the category dataset to use \f$ c_1 \f$ (used for x-coordinates)
2447 \param inLastCat_X iterator pointing behind the last item in the category dataset to use \f$ c_N \f$ (used for x-coordinates)
2448 \param inFirstValue_Y iterator pointing to the first item in the category dataset to use \f$ v_1 \f$ (used for y-coordinates)
2449 \param inLastValue_Y iterator pointing behind the last item in the category dataset to use \f$ v_N \f$ (used for y-coordinates)
2450 \param groupDefFunc assigns a group \f$ c_{\text{out},j} \f$ to each category value \f$ c_i \f$ .
2451 \param columnBaseName string component used to build the names of the columns generated by this function
2452 \return the graph showing \f$ c_{\text{out},j} \f$ and average +/- stddev for each group \f$ j \f$
2453
2454
2455
2456 \see jkqtpstatGroupData(), jkqtpstatAddYErrorGraph(), JKQTPImpulsesVerticalErrorGraph, \ref JKQTPlotterBasicJKQTPDatastoreStatisticsGroupedStat
2457*/
2458template <class InputCatIt, class InputValueIt>
2459inline JKQTPImpulsesVerticalErrorGraph* jkqtpstatAddYErrorImpulsesGraph(JKQTBasePlotter* plotter, InputCatIt inFirstCat_X, InputCatIt inLastCat_X, InputValueIt inFirstValue_Y, InputValueIt inLastValue_Y, JKQTPStatGroupDefinitionFunctor1D groupDefFunc=&jkqtpstatGroupingIdentity1D, const QString& columnBaseName=QString("grouped data")) {
2460 return jkqtpstatAddYErrorGraph<InputCatIt,InputValueIt,JKQTPImpulsesVerticalErrorGraph>(plotter,inFirstCat_X, inLastCat_X, inFirstValue_Y, inLastValue_Y, groupDefFunc, columnBaseName);
2461}
2462
2463
2464/*! \brief create a \c JKQTPXYParametrizedErrorScatterGraph with y-direction error bars, calculated from average +/- stddev of groups in the input data
2465 \ingroup jkqtptools_math_statistics_adaptors
2466
2467 \tparam InputCatIt standard iterator type of \a inFirstCat_X and \a inLastCat_X
2468 \tparam InputValueIt standard iterator type of \a inFirstValue_Y and \a inLastValue_Y
2469 \param plotter the plotter to which to add the resulting graph
2470 \param inFirstCat_X iterator pointing to the first item in the category dataset to use \f$ c_1 \f$ (used for x-coordinates)
2471 \param inLastCat_X iterator pointing behind the last item in the category dataset to use \f$ c_N \f$ (used for x-coordinates)
2472 \param inFirstValue_Y iterator pointing to the first item in the category dataset to use \f$ v_1 \f$ (used for y-coordinates)
2473 \param inLastValue_Y iterator pointing behind the last item in the category dataset to use \f$ v_N \f$ (used for y-coordinates)
2474 \param groupDefFunc assigns a group \f$ c_{\text{out},j} \f$ to each category value \f$ c_i \f$ .
2475 \param columnBaseName string component used to build the names of the columns generated by this function
2476 \return the graph showing \f$ c_{\text{out},j} \f$ and average +/- stddev for each group \f$ j \f$
2477
2478
2479
2480 \see jkqtpstatGroupData(), jkqtpstatAddYErrorGraph(), JKQTPXYParametrizedErrorScatterGraph, \ref JKQTPlotterBasicJKQTPDatastoreStatisticsGroupedStat
2481*/
2482template <class InputCatIt, class InputValueIt>
2483inline JKQTPXYParametrizedErrorScatterGraph* jkqtpstatAddYErrorParametrizedScatterGraph(JKQTBasePlotter* plotter, InputCatIt inFirstCat_X, InputCatIt inLastCat_X, InputValueIt inFirstValue_Y, InputValueIt inLastValue_Y, JKQTPStatGroupDefinitionFunctor1D groupDefFunc=&jkqtpstatGroupingIdentity1D, const QString& columnBaseName=QString("grouped data")) {
2484 return jkqtpstatAddYErrorGraph<InputCatIt,InputValueIt,JKQTPXYParametrizedErrorScatterGraph>(plotter,inFirstCat_X, inLastCat_X, inFirstValue_Y, inLastValue_Y, groupDefFunc, columnBaseName);
2485}
2486
2487
2488/*! \brief create a \c JKQTPFilledCurveYErrorGraph with y-direction error bars, calculated from average +/- stddev of groups in the input data
2489 \ingroup jkqtptools_math_statistics_adaptors
2490
2491 \tparam InputCatIt standard iterator type of \a inFirstCat_X and \a inLastCat_X
2492 \tparam InputValueIt standard iterator type of \a inFirstValue_Y and \a inLastValue_Y
2493 \param plotter the plotter to which to add the resulting graph
2494 \param inFirstCat_X iterator pointing to the first item in the category dataset to use \f$ c_1 \f$ (used for x-coordinates)
2495 \param inLastCat_X iterator pointing behind the last item in the category dataset to use \f$ c_N \f$ (used for x-coordinates)
2496 \param inFirstValue_Y iterator pointing to the first item in the category dataset to use \f$ v_1 \f$ (used for y-coordinates)
2497 \param inLastValue_Y iterator pointing behind the last item in the category dataset to use \f$ v_N \f$ (used for y-coordinates)
2498 \param groupDefFunc assigns a group \f$ c_{\text{out},j} \f$ to each category value \f$ c_i \f$ .
2499 \param columnBaseName string component used to build the names of the columns generated by this function
2500 \return the graph showing \f$ c_{\text{out},j} \f$ and average +/- stddev for each group \f$ j \f$
2501
2502
2503
2504 \see jkqtpstatGroupData(), jkqtpstatAddYErrorGraph(), JKQTPFilledCurveYErrorGraph, \ref JKQTPlotterBasicJKQTPDatastoreStatisticsGroupedStat
2505*/
2506template <class InputCatIt, class InputValueIt>
2507inline JKQTPFilledCurveYErrorGraph* jkqtpstatAddYErrorFilledCurveGraph(JKQTBasePlotter* plotter, InputCatIt inFirstCat_X, InputCatIt inLastCat_X, InputValueIt inFirstValue_Y, InputValueIt inLastValue_Y, JKQTPStatGroupDefinitionFunctor1D groupDefFunc=&jkqtpstatGroupingIdentity1D, const QString& columnBaseName=QString("grouped data")) {
2508 return jkqtpstatAddYErrorGraph<InputCatIt,InputValueIt,JKQTPFilledCurveYErrorGraph>(plotter,inFirstCat_X, inLastCat_X, inFirstValue_Y, inLastValue_Y, groupDefFunc, columnBaseName);
2509}
2510
2511
2512
2513
2514
2515
2516
2517/*! \brief create a plot with x-direction error bars, calculated from average +/- stddev of groups in the input data
2518 \ingroup jkqtptools_math_statistics_adaptors
2519
2520 \tparam TGraph type of graph that should be added to the plot
2521 \tparam InputCatIt standard iterator type of \a inFirstCat_Y and \a inLastCat_Y
2522 \tparam InputValueIt standard iterator type of \a inFirstValue_Y and \a inLastValue_Y
2523 \param plotter the plotter to which to add the resulting graph
2524 \param inFirstCat_Y iterator pointing to the first item in the category dataset to use \f$ c_1 \f$ (used for y-coordinates)
2525 \param inLastCat_Y iterator pointing behind the last item in the category dataset to use \f$ c_N \f$ (used for y-coordinates)
2526 \param inFirstValue_Y iterator pointing to the first item in the category dataset to use \f$ v_1 \f$ (used for x-coordinates)
2527 \param inLastValue_Y iterator pointing behind the last item in the category dataset to use \f$ v_N \f$ (used for x-coordinates)
2528 \param groupDefFunc assigns a group \f$ c_{\text{out},j} \f$ to each category value \f$ c_i \f$ .
2529 \param columnBaseName string component used to build the names of the columns generated by this function
2530 \return the graph showing \f$ c_{\text{out},j} \f$ and average +/- stddev for each group \f$ j \f$
2531
2532
2533
2534 \see jkqtpstatGroupData(), \ref JKQTPlotterBasicJKQTPDatastoreStatisticsGroupedStat
2535*/
2536template <class InputCatIt, class InputValueIt, class TGraph>
2537inline TGraph* jkqtpstatAddXErrorGraph(JKQTBasePlotter* plotter, InputCatIt inFirstCat_Y, InputCatIt inLastCat_Y, InputValueIt inFirstValue_Y, InputValueIt inLastValue_Y, JKQTPStatGroupDefinitionFunctor1D groupDefFunc=&jkqtpstatGroupingIdentity1D, const QString& columnBaseName=QString("grouped data")) {
2538 std::map<double, std::vector<double> > groupeddataBar;
2539 jkqtpstatGroupData(inFirstCat_Y, inLastCat_Y, inFirstValue_Y, inLastValue_Y, groupeddataBar, groupDefFunc);
2540
2541 size_t colGroup=plotter->getDatastore()->addColumn(columnBaseName+", group");
2542 size_t colAverage=plotter->getDatastore()->addColumn(columnBaseName+", average");
2543 size_t colStdDev=plotter->getDatastore()->addColumn(columnBaseName+", stddev");
2544
2545 for (auto it=groupeddataBar.begin(); it!=groupeddataBar.end(); ++it) {
2546 plotter->getDatastore()->appendToColumn(colGroup, it->first);
2547 plotter->getDatastore()->appendToColumn(colAverage, jkqtpstatAverage(it->second.begin(), it->second.end()));
2548 plotter->getDatastore()->appendToColumn(colStdDev, jkqtpstatStdDev(it->second.begin(), it->second.end()));
2549 }
2550
2551 // 2.4. Finally the calculated groups are drawn
2552 TGraph* graph;
2553 plotter->addGraph(graph=new TGraph(plotter));
2554 graph->setXColumn(colAverage);
2555 graph->setYColumn(colGroup);
2556 graph->setXErrorColumn(static_cast<int>(colStdDev));
2557
2558 return graph;
2559}
2560
2561
2562/*! \brief create a \c JKQTPXYLineErrorGraph with x-direction error bars, calculated from average +/- stddev of groups in the input data
2563 \ingroup jkqtptools_math_statistics_adaptors
2564
2565 \tparam InputCatIt standard iterator type of \a inFirstCat_Y and \a inLastCat_Y
2566 \tparam InputValueIt standard iterator type of \a inFirstValue_Y and \a inLastValue_Y
2567 \param plotter the plotter to which to add the resulting graph
2568 \param inFirstCat_Y iterator pointing to the first item in the category dataset to use \f$ c_1 \f$ (used for y-coordinates)
2569 \param inLastCat_Y iterator pointing behind the last item in the category dataset to use \f$ c_N \f$ (used for y-coordinates)
2570 \param inFirstValue_Y iterator pointing to the first item in the category dataset to use \f$ v_1 \f$ (used for x-coordinates)
2571 \param inLastValue_Y iterator pointing behind the last item in the category dataset to use \f$ v_N \f$ (used for x-coordinates)
2572 \param groupDefFunc assigns a group \f$ c_{\text{out},j} \f$ to each category value \f$ c_i \f$ .
2573 \param columnBaseName string component used to build the names of the columns generated by this function
2574 \return the graph showing \f$ c_{\text{out},j} \f$ and average +/- stddev for each group \f$ j \f$
2575
2576
2577
2578 \see jkqtpstatGroupData(), jkqtpstatAddXErrorGraph(), JKQTPXYLineErrorGraph, \ref JKQTPlotterBasicJKQTPDatastoreStatisticsGroupedStat
2579*/
2580template <class InputCatIt, class InputValueIt>
2581inline JKQTPXYLineErrorGraph* jkqtpstatAddXErrorLineGraph(JKQTBasePlotter* plotter, InputCatIt inFirstCat_Y, InputCatIt inLastCat_Y, InputValueIt inFirstValue_Y, InputValueIt inLastValue_Y, JKQTPStatGroupDefinitionFunctor1D groupDefFunc=&jkqtpstatGroupingIdentity1D, const QString& columnBaseName=QString("grouped data")) {
2582 return jkqtpstatAddXErrorGraph<InputCatIt,InputValueIt,JKQTPXYLineErrorGraph>(plotter,inFirstCat_Y, inLastCat_Y, inFirstValue_Y, inLastValue_Y, groupDefFunc, columnBaseName);
2583}
2584
2585
2586/*! \brief create a \c JKQTPBarHorizontalErrorGraph with x-direction error bars, calculated from average +/- stddev of groups in the input data
2587 \ingroup jkqtptools_math_statistics_adaptors
2588
2589 \tparam InputCatIt standard iterator type of \a inFirstCat_Y and \a inLastCat_Y
2590 \tparam InputValueIt standard iterator type of \a inFirstValue_Y and \a inLastValue_Y
2591 \param plotter the plotter to which to add the resulting graph
2592 \param inFirstCat_Y iterator pointing to the first item in the category dataset to use \f$ c_1 \f$ (used for y-coordinates)
2593 \param inLastCat_Y iterator pointing behind the last item in the category dataset to use \f$ c_N \f$ (used for y-coordinates)
2594 \param inFirstValue_Y iterator pointing to the first item in the category dataset to use \f$ v_1 \f$ (used for x-coordinates)
2595 \param inLastValue_Y iterator pointing behind the last item in the category dataset to use \f$ v_N \f$ (used for x-coordinates)
2596 \param groupDefFunc assigns a group \f$ c_{\text{out},j} \f$ to each category value \f$ c_i \f$ .
2597 \param columnBaseName string component used to build the names of the columns generated by this function
2598 \return the graph showing \f$ c_{\text{out},j} \f$ and average +/- stddev for each group \f$ j \f$
2599
2600
2601
2602 \see jkqtpstatGroupData(), jkqtpstatAddXErrorGraph(), JKQTPBarHorizontalErrorGraph, \ref JKQTPlotterBasicJKQTPDatastoreStatisticsGroupedStat
2603*/
2604template <class InputCatIt, class InputValueIt>
2605inline JKQTPBarHorizontalErrorGraph* jkqtpstatAddXErrorBarGraph(JKQTBasePlotter* plotter, InputCatIt inFirstCat_Y, InputCatIt inLastCat_Y, InputValueIt inFirstValue_Y, InputValueIt inLastValue_Y, JKQTPStatGroupDefinitionFunctor1D groupDefFunc=&jkqtpstatGroupingIdentity1D, const QString& columnBaseName=QString("grouped data")) {
2606 return jkqtpstatAddXErrorGraph<InputCatIt,InputValueIt,JKQTPBarHorizontalErrorGraph>(plotter,inFirstCat_Y, inLastCat_Y, inFirstValue_Y, inLastValue_Y, groupDefFunc, columnBaseName);
2607}
2608
2609
2610/*! \brief create a \c JKQTPImpulsesHorizontalErrorGraph with x-direction error bars, calculated from average +/- stddev of groups in the input data
2611 \ingroup jkqtptools_math_statistics_adaptors
2612
2613 \tparam InputCatIt standard iterator type of \a inFirstCat_Y and \a inLastCat_Y
2614 \tparam InputValueIt standard iterator type of \a inFirstValue_Y and \a inLastValue_Y
2615 \param plotter the plotter to which to add the resulting graph
2616 \param inFirstCat_Y iterator pointing to the first item in the category dataset to use \f$ c_1 \f$ (used for y-coordinates)
2617 \param inLastCat_Y iterator pointing behind the last item in the category dataset to use \f$ c_N \f$ (used for y-coordinates)
2618 \param inFirstValue_Y iterator pointing to the first item in the category dataset to use \f$ v_1 \f$ (used for x-coordinates)
2619 \param inLastValue_Y iterator pointing behind the last item in the category dataset to use \f$ v_N \f$ (used for x-coordinates)
2620 \param groupDefFunc assigns a group \f$ c_{\text{out},j} \f$ to each category value \f$ c_i \f$ .
2621 \param columnBaseName string component used to build the names of the columns generated by this function
2622 \return the graph showing \f$ c_{\text{out},j} \f$ and average +/- stddev for each group \f$ j \f$
2623
2624
2625
2626 \see jkqtpstatGroupData(), jkqtpstatAddXErrorGraph(), JKQTPImpulsesHorizontalErrorGraph, \ref JKQTPlotterBasicJKQTPDatastoreStatisticsGroupedStat
2627*/
2628template <class InputCatIt, class InputValueIt>
2629inline JKQTPImpulsesHorizontalErrorGraph* jkqtpstatAddXErrorImpulsesGraph(JKQTBasePlotter* plotter, InputCatIt inFirstCat_Y, InputCatIt inLastCat_Y, InputValueIt inFirstValue_Y, InputValueIt inLastValue_Y, JKQTPStatGroupDefinitionFunctor1D groupDefFunc=&jkqtpstatGroupingIdentity1D, const QString& columnBaseName=QString("grouped data")) {
2630 return jkqtpstatAddXErrorGraph<InputCatIt,InputValueIt,JKQTPImpulsesHorizontalErrorGraph>(plotter,inFirstCat_Y, inLastCat_Y, inFirstValue_Y, inLastValue_Y, groupDefFunc, columnBaseName);
2631}
2632
2633
2634/*! \brief create a \c JKQTPXYParametrizedErrorScatterGraph with x-direction error bars, calculated from average +/- stddev of groups in the input data
2635 \ingroup jkqtptools_math_statistics_adaptors
2636
2637 \tparam InputCatIt standard iterator type of \a inFirstCat_Y and \a inLastCat_Y
2638 \tparam InputValueIt standard iterator type of \a inFirstValue_Y and \a inLastValue_Y
2639 \param plotter the plotter to which to add the resulting graph
2640 \param inFirstCat_Y iterator pointing to the first item in the category dataset to use \f$ c_1 \f$ (used for y-coordinates)
2641 \param inLastCat_Y iterator pointing behind the last item in the category dataset to use \f$ c_N \f$ (used for y-coordinates)
2642 \param inFirstValue_Y iterator pointing to the first item in the category dataset to use \f$ v_1 \f$ (used for x-coordinates)
2643 \param inLastValue_Y iterator pointing behind the last item in the category dataset to use \f$ v_N \f$ (used for x-coordinates)
2644 \param groupDefFunc assigns a group \f$ c_{\text{out},j} \f$ to each category value \f$ c_i \f$ .
2645 \param columnBaseName string component used to build the names of the columns generated by this function
2646 \return the graph showing \f$ c_{\text{out},j} \f$ and average +/- stddev for each group \f$ j \f$
2647
2648
2649
2650 \see jkqtpstatGroupData(), jkqtpstatAddXErrorGraph(), JKQTPXYParametrizedErrorScatterGraph, \ref JKQTPlotterBasicJKQTPDatastoreStatisticsGroupedStat
2651*/
2652template <class InputCatIt, class InputValueIt>
2653inline JKQTPXYParametrizedErrorScatterGraph* jkqtpstatAddXErrorParametrizedScatterGraph(JKQTBasePlotter* plotter, InputCatIt inFirstCat_Y, InputCatIt inLastCat_Y, InputValueIt inFirstValue_Y, InputValueIt inLastValue_Y, JKQTPStatGroupDefinitionFunctor1D groupDefFunc=&jkqtpstatGroupingIdentity1D, const QString& columnBaseName=QString("grouped data")) {
2654 return jkqtpstatAddXErrorGraph<InputCatIt,InputValueIt,JKQTPXYParametrizedErrorScatterGraph>(plotter,inFirstCat_Y, inLastCat_Y, inFirstValue_Y, inLastValue_Y, groupDefFunc, columnBaseName);
2655}
2656
2657
2658/*! \brief create a JKQTPFilledCurveXErrorGraph with x-direction error bars, calculated from average +/- stddev of groups in the input data
2659 \ingroup jkqtptools_math_statistics_adaptors
2660
2661 \tparam InputCatIt standard iterator type of \a inFirstCat_Y and \a inLastCat_Y
2662 \tparam InputValueIt standard iterator type of \a inFirstValue_Y and \a inLastValue_Y
2663 \param plotter the plotter to which to add the resulting graph
2664 \param inFirstCat_Y iterator pointing to the first item in the category dataset to use \f$ c_1 \f$ (used for y-coordinates)
2665 \param inLastCat_Y iterator pointing behind the last item in the category dataset to use \f$ c_N \f$ (used for y-coordinates)
2666 \param inFirstValue_Y iterator pointing to the first item in the category dataset to use \f$ v_1 \f$ (used for x-coordinates)
2667 \param inLastValue_Y iterator pointing behind the last item in the category dataset to use \f$ v_N \f$ (used for x-coordinates)
2668 \param groupDefFunc assigns a group \f$ c_{\text{out},j} \f$ to each category value \f$ c_i \f$ .
2669 \param columnBaseName string component used to build the names of the columns generated by this function
2670 \return the graph showing \f$ c_{\text{out},j} \f$ and average +/- stddev for each group \f$ j \f$
2671
2672
2673
2674 \see jkqtpstatGroupData(), jkqtpstatAddXErrorGraph(), JKQTPFilledCurveXErrorGraph, \ref JKQTPlotterBasicJKQTPDatastoreStatisticsGroupedStat
2675*/
2676template <class InputCatIt, class InputValueIt>
2677inline JKQTPFilledCurveXErrorGraph* jkqtpstatAddXErrorFilledCurveGraph(JKQTBasePlotter* plotter, InputCatIt inFirstCat_Y, InputCatIt inLastCat_Y, InputValueIt inFirstValue_Y, InputValueIt inLastValue_Y, JKQTPStatGroupDefinitionFunctor1D groupDefFunc=&jkqtpstatGroupingIdentity1D, const QString& columnBaseName=QString("grouped data")) {
2678 return jkqtpstatAddXErrorGraph<InputCatIt,InputValueIt,JKQTPFilledCurveXErrorGraph>(plotter,inFirstCat_Y, inLastCat_Y, inFirstValue_Y, inLastValue_Y, groupDefFunc, columnBaseName);
2679}
2680
2681
2682
2683
2684
2685
2686
2687
2688/*! \brief create a plot with x- and y-direction error bars, calculated from directional average +/- stddev of groups in the input data
2689 \ingroup jkqtptools_math_statistics_adaptors
2690
2691 \tparam TGraph type of graph that should be added to the plot
2692 \tparam InputCatIt standard iterator type of \a inFirstCat_X and \a inLastCat_X
2693 \tparam InputValueIt standard iterator type of \a inFirstValue_Y and \a inLastValue_Y
2694 \param plotter the plotter to which to add the resulting graph
2695 \param inFirstCat_X iterator pointing to the first item in the category dataset to use \f$ c_1 \f$ (used for x-coordinates)
2696 \param inLastCat_X iterator pointing behind the last item in the category dataset to use \f$ c_N \f$ (used for x-coordinates)
2697 \param inFirstValue_Y iterator pointing to the first item in the category dataset to use \f$ v_1 \f$ (used for y-coordinates)
2698 \param inLastValue_Y iterator pointing behind the last item in the category dataset to use \f$ v_N \f$ (used for y-coordinates)
2699 \param groupDefFunc assigns a group \f$ c_{\text{out},j} \f$ to each category value \f$ c_i \f$ .
2700 \param columnBaseName string component used to build the names of the columns generated by this function
2701 \return the graph showing \f$ c_{\text{out},j} \f$ and average +/- stddev for each group \f$ j \f$
2702
2703
2704
2705 \see jkqtpstatGroupData(), \ref JKQTPlotterBasicJKQTPDatastoreStatisticsGroupedStat
2706*/
2707template <class InputCatIt, class InputValueIt, class TGraph>
2708inline TGraph* jkqtpstatAddXYErrorGraph(JKQTBasePlotter* plotter, InputCatIt inFirstCat_X, InputCatIt inLastCat_X, InputValueIt inFirstValue_Y, InputValueIt inLastValue_Y, JKQTPStatGroupDefinitionFunctor1D groupDefFunc=&jkqtpstatGroupingIdentity1D, const QString& columnBaseName=QString("grouped data")) {
2709 std::map<double, std::pair< std::vector<double>, std::vector<double> > > groupeddataBar;
2710 jkqtpstatGroupData(inFirstCat_X, inLastCat_X, inFirstValue_Y, inLastValue_Y, groupeddataBar, groupDefFunc);
2711
2712 size_t colGroup=plotter->getDatastore()->addColumn(columnBaseName+", group");
2713 size_t colAverageX=plotter->getDatastore()->addColumn(columnBaseName+", category-average");
2714 size_t colStdDevX=plotter->getDatastore()->addColumn(columnBaseName+", category-stddev");
2715 size_t colAverageY=plotter->getDatastore()->addColumn(columnBaseName+", value-average");
2716 size_t colStdDevY=plotter->getDatastore()->addColumn(columnBaseName+", value-stddev");
2717
2718 for (auto it=groupeddataBar.begin(); it!=groupeddataBar.end(); ++it) {
2719 plotter->getDatastore()->appendToColumn(colGroup, it->first);
2720 plotter->getDatastore()->appendToColumn(colAverageX, jkqtpstatAverage(it->second.first.begin(), it->second.first.end()));
2721 plotter->getDatastore()->appendToColumn(colStdDevX, jkqtpstatStdDev(it->second.first.begin(), it->second.first.end()));
2722 plotter->getDatastore()->appendToColumn(colAverageY, jkqtpstatAverage(it->second.second.begin(), it->second.second.end()));
2723 plotter->getDatastore()->appendToColumn(colStdDevY, jkqtpstatStdDev(it->second.second.begin(), it->second.second.end()));
2724 }
2725
2726 // 2.4. Finally the calculated groups are drawn
2727 TGraph* graph;
2728 plotter->addGraph(graph=new TGraph(plotter));
2729 graph->setXColumn(colAverageX);
2730 graph->setYColumn(colAverageY);
2731 graph->setXErrorColumn(static_cast<int>(colStdDevX));
2732 graph->setYErrorColumn(static_cast<int>(colStdDevY));
2733
2734 return graph;
2735}
2736
2737
2738/*! \brief create a \c JKQTPXYLineErrorGraph with y-direction error bars, calculated from average +/- stddev of groups in the input data
2739 \ingroup jkqtptools_math_statistics_adaptors
2740
2741 \tparam InputCatIt standard iterator type of \a inFirstCat_X and \a inLastCat_X
2742 \tparam InputValueIt standard iterator type of \a inFirstValue_Y and \a inLastValue_Y
2743 \param plotter the plotter to which to add the resulting graph
2744 \param inFirstCat_X iterator pointing to the first item in the category dataset to use \f$ c_1 \f$ (used for x-coordinates)
2745 \param inLastCat_X iterator pointing behind the last item in the category dataset to use \f$ c_N \f$ (used for x-coordinates)
2746 \param inFirstValue_Y iterator pointing to the first item in the category dataset to use \f$ v_1 \f$ (used for y-coordinates)
2747 \param inLastValue_Y iterator pointing behind the last item in the category dataset to use \f$ v_N \f$ (used for y-coordinates)
2748 \param groupDefFunc assigns a group \f$ c_{\text{out},j} \f$ to each category value \f$ c_i \f$ .
2749 \param columnBaseName string component used to build the names of the columns generated by this function
2750 \return the graph showing \f$ c_{\text{out},j} \f$ and average +/- stddev for each group \f$ j \f$
2751
2752
2753
2754 \see jkqtpstatGroupData(), jkqtpstatAddXYErrorGraph(), JKQTPXYLineErrorGraph, \ref JKQTPlotterBasicJKQTPDatastoreStatisticsGroupedStat
2755*/
2756template <class InputCatIt, class InputValueIt>
2757inline JKQTPXYLineErrorGraph* jkqtpstatAddXYErrorLineGraph(JKQTBasePlotter* plotter, InputCatIt inFirstCat_X, InputCatIt inLastCat_X, InputValueIt inFirstValue_Y, InputValueIt inLastValue_Y, JKQTPStatGroupDefinitionFunctor1D groupDefFunc=&jkqtpstatGroupingIdentity1D, const QString& columnBaseName=QString("grouped data")) {
2758 return jkqtpstatAddXYErrorGraph<InputCatIt,InputValueIt,JKQTPXYLineErrorGraph>(plotter,inFirstCat_X, inLastCat_X, inFirstValue_Y, inLastValue_Y, groupDefFunc, columnBaseName);
2759}
2760
2761
2762
2763/*! \brief create a \c JKQTPXYParametrizedErrorScatterGraph with y-direction error bars, calculated from average +/- stddev of groups in the input data
2764 \ingroup jkqtptools_math_statistics_adaptors
2765
2766 \tparam InputCatIt standard iterator type of \a inFirstCat_X and \a inLastCat_X
2767 \tparam InputValueIt standard iterator type of \a inFirstValue_Y and \a inLastValue_Y
2768 \param plotter the plotter to which to add the resulting graph
2769 \param inFirstCat_X iterator pointing to the first item in the category dataset to use \f$ c_1 \f$ (used for x-coordinates)
2770 \param inLastCat_X iterator pointing behind the last item in the category dataset to use \f$ c_N \f$ (used for x-coordinates)
2771 \param inFirstValue_Y iterator pointing to the first item in the category dataset to use \f$ v_1 \f$ (used for y-coordinates)
2772 \param inLastValue_Y iterator pointing behind the last item in the category dataset to use \f$ v_N \f$ (used for y-coordinates)
2773 \param groupDefFunc assigns a group \f$ c_{\text{out},j} \f$ to each category value \f$ c_i \f$ .
2774 \param columnBaseName string component used to build the names of the columns generated by this function
2775 \return the graph showing \f$ c_{\text{out},j} \f$ and average +/- stddev for each group \f$ j \f$
2776
2777
2778
2779 \see jkqtpstatGroupData(), jkqtpstatAddXYErrorGraph(), JKQTPXYParametrizedErrorScatterGraph, \ref JKQTPlotterBasicJKQTPDatastoreStatisticsGroupedStat
2780*/
2781template <class InputCatIt, class InputValueIt>
2782inline JKQTPXYParametrizedErrorScatterGraph* jkqtpstatAddXYErrorParametrizedScatterGraph(JKQTBasePlotter* plotter, InputCatIt inFirstCat_X, InputCatIt inLastCat_X, InputValueIt inFirstValue_Y, InputValueIt inLastValue_Y, JKQTPStatGroupDefinitionFunctor1D groupDefFunc=&jkqtpstatGroupingIdentity1D, const QString& columnBaseName=QString("grouped data")) {
2783 return jkqtpstatAddXYErrorGraph<InputCatIt,InputValueIt,JKQTPXYParametrizedErrorScatterGraph>(plotter,inFirstCat_X, inLastCat_X, inFirstValue_Y, inLastValue_Y, groupDefFunc, columnBaseName);
2784}
2785
2786
2787
2788
2789
2790/*! \brief create horizontal boxplots of type \c TGraph, from the 5-value-summary of groups in the input data
2791 \ingroup jkqtptools_math_statistics_adaptors
2792 \internal
2793
2794 \tparam TGraph type of graph that should be added to the plot, has to offer the same interface as JKQTPBoxplotVerticalGraph or JKQTPBoxplotHorizontalGraph
2795 \tparam InputCatIt standard iterator type of \a inFirstCat_Y and \a inLastCat_Y
2796 \tparam InputValueIt standard iterator type of \a inFirstValue_Y and \a inLastValue_Y
2797 \param plotter the plotter to which to add the resulting graph
2798 \param inFirstCat_Y iterator pointing to the first item in the category dataset to use \f$ c_1 \f$ (used for y-coordinates)
2799 \param inLastCat_Y iterator pointing behind the last item in the category dataset to use \f$ c_N \f$ (used for y-coordinates)
2800 \param inFirstValue_Y iterator pointing to the first item in the category dataset to use \f$ v_1 \f$ (used for x-coordinates)
2801 \param inLastValue_Y iterator pointing behind the last item in the category dataset to use \f$ v_N \f$ (used for x-coordinates)
2802 \param quantile1Spec specifies which quantile to calculate for \a qantile1 (range: 0..1)
2803 \param quantile2Spec specifies which quantile to calculate for \a qantile2 (range: 0..1)
2804 \param minimumQuantile specifies a quantile for the return value minimum (default is 0 for the real minimum, but you could e.g. use 0.05 for the 5% quantile!)
2805 \param maximumQuantile specifies a quantile for the return value maximum (default is 1 for the real maximum, but you could e.g. use 0.95 for the 95% quantile!)
2806 \param groupDefFunc assigns a group \f$ c_{\text{out},j} \f$ to each category value \f$ c_i \f$ .
2807 \param columnBaseName string component used to build the names of the columns generated by this function
2808 \return the boxplot graph
2809
2810
2811
2812 \see jkqtpstatGroupData(), \ref JKQTPlotterBasicJKQTPDatastoreStatisticsGroupedStat
2813*/
2814template <class InputCatIt, class InputValueIt, class TGraph>
2815inline TGraph* jkqtpstatAddBoxplots(JKQTBasePlotter* plotter, InputCatIt inFirstCat_Y, InputCatIt inLastCat_Y, InputValueIt inFirstValue_Y, InputValueIt inLastValue_Y, double quantile1Spec=0.25, double quantile2Spec=0.75, double minimumQuantile=0, double maximumQuantile=1.0, JKQTPStatGroupDefinitionFunctor1D groupDefFunc=&jkqtpstatGroupingIdentity1D, const QString& columnBaseName=QString("grouped boxplot data")) {
2816 std::map<double, std::vector<double> > groupeddataBar;
2817 jkqtpstatGroupData(inFirstCat_Y, inLastCat_Y, inFirstValue_Y, inLastValue_Y, groupeddataBar, groupDefFunc);
2818
2819 size_t colGroup=plotter->getDatastore()->addColumn(columnBaseName+", group");
2820 size_t colMin=plotter->getDatastore()->addColumn(columnBaseName+", minimum");
2821 size_t colQ25=plotter->getDatastore()->addColumn(columnBaseName+", quartile25");
2822 size_t colMedian=plotter->getDatastore()->addColumn(columnBaseName+", median");
2823 size_t colIQRSig=plotter->getDatastore()->addColumn(columnBaseName+", MedianSignificance");
2824 size_t colAverage=plotter->getDatastore()->addColumn(columnBaseName+", average");
2825 size_t colQ75=plotter->getDatastore()->addColumn(columnBaseName+", quartile75");
2826 size_t colMax=plotter->getDatastore()->addColumn(columnBaseName+", maximum");
2827
2828 for (auto it=groupeddataBar.begin(); it!=groupeddataBar.end(); ++it) {
2829
2830 auto stat5=jkqtpstat5NumberStatistics(it->second.begin(), it->second.end(), quantile1Spec, quantile2Spec, minimumQuantile, maximumQuantile);
2831
2832 plotter->getDatastore()->appendToColumn(colGroup, it->first);
2833 plotter->getDatastore()->appendToColumn(colAverage, jkqtpstatAverage(it->second.begin(), it->second.end()));
2834 plotter->getDatastore()->appendToColumn(colMin, stat5.minimum);
2835 plotter->getDatastore()->appendToColumn(colQ25, stat5.quantile1);
2836 plotter->getDatastore()->appendToColumn(colMedian, stat5.median);
2837 plotter->getDatastore()->appendToColumn(colQ75, stat5.quantile2);
2838 plotter->getDatastore()->appendToColumn(colMax, stat5.maximum);
2839 plotter->getDatastore()->appendToColumn(colIQRSig, stat5.IQRSignificanceEstimate());
2840 }
2841
2842 // 2.4. Finally the calculated groups are drawn
2843 TGraph* graph;
2844 plotter->addGraph(graph=new TGraph(plotter));
2845 graph->setPositionColumn(colGroup);
2846 graph->setMinColumn(colMin);
2847 graph->setMaxColumn(colMax);
2848 graph->setMedianColumn(colMedian);
2849 graph->setMeanColumn(colAverage);
2850 graph->setPercentile25Column(colQ25);
2851 graph->setPercentile75Column(colQ75);
2852 graph->setMedianConfidenceColumn(colIQRSig);
2853
2854 return graph;
2855}
2856
2857/*! \brief create vertical boxplots of type \c JKQTPBoxplotVerticalGraph, from the 5-value-summary of groups in the input data
2858 \ingroup jkqtptools_math_statistics_adaptors
2859 \internal
2860
2861 \tparam InputCatIt standard iterator type of \a inFirstCat_Y and \a inLastCat_Y
2862 \tparam InputValueIt standard iterator type of \a inFirstValue_X and \a inLastValue_X
2863 \param plotter the plotter to which to add the resulting graph
2864 \param inFirstCat_Y iterator pointing to the first item in the category dataset to use \f$ c_1 \f$ (used for y-coordinates)
2865 \param inLastCat_Y iterator pointing behind the last item in the category dataset to use \f$ c_N \f$ (used for y-coordinates)
2866 \param inFirstValue_X iterator pointing to the first item in the category dataset to use \f$ v_1 \f$ (used for x-coordinates)
2867 \param inLastValue_X iterator pointing behind the last item in the category dataset to use \f$ v_N \f$ (used for x-coordinates)
2868 \param quantile1Spec specifies which quantile to calculate for \a qantile1 (range: 0..1)
2869 \param quantile2Spec specifies which quantile to calculate for \a qantile2 (range: 0..1)
2870 \param minimumQuantile specifies a quantile for the return value minimum (default is 0 for the real minimum, but you could e.g. use 0.05 for the 5% quantile!)
2871 \param maximumQuantile specifies a quantile for the return value maximum (default is 1 for the real maximum, but you could e.g. use 0.95 for the 95% quantile!)
2872 \param groupDefFunc assigns a group \f$ c_{\text{out},j} \f$ to each category value \f$ c_i \f$ .
2873 \param columnBaseName string component used to build the names of the columns generated by this function
2874 \return the boxplot graph
2875
2876
2877
2878 \see jkqtpstatGroupData(), \ref JKQTPlotterBasicJKQTPDatastoreStatisticsGroupedStat
2879*/
2880template <class InputCatIt, class InputValueIt>
2881inline JKQTPBoxplotVerticalGraph* jkqtpstatVAddBoxplots(JKQTBasePlotter* plotter, InputCatIt inFirstCat_Y, InputCatIt inLastCat_Y, InputValueIt inFirstValue_X, InputValueIt inLastValue_X, double quantile1Spec=0.25, double quantile2Spec=0.75, double minimumQuantile=0, double maximumQuantile=1.0, JKQTPStatGroupDefinitionFunctor1D groupDefFunc=&jkqtpstatGroupingIdentity1D, const QString& columnBaseName=QString("grouped boxplot data")) {
2882
2883 return jkqtpstatAddBoxplots<InputCatIt,InputValueIt,JKQTPBoxplotVerticalGraph>(plotter, inFirstCat_Y, inLastCat_Y, inFirstValue_X, inLastValue_X, quantile1Spec, quantile2Spec, minimumQuantile, maximumQuantile, groupDefFunc, columnBaseName);
2884}
2885
2886/*! \brief create horizontal boxplots of type \c JKQTPBoxplotHorizontalGraph, from the 5-value-summary of groups in the input data
2887 \ingroup jkqtptools_math_statistics_adaptors
2888 \internal
2889
2890 \tparam InputCatIt standard iterator type of \a inFirstCat_X and \a inLastCat_X
2891 \tparam InputValueIt standard iterator type of \a inFirstValue_Y and \a inLastValue_Y
2892 \param plotter the plotter to which to add the resulting graph
2893 \param inFirstCat_X iterator pointing to the first item in the category dataset to use \f$ c_1 \f$ (used for y-coordinates)
2894 \param inLastCat_X iterator pointing behind the last item in the category dataset to use \f$ c_N \f$ (used for y-coordinates)
2895 \param inFirstValue_Y iterator pointing to the first item in the category dataset to use \f$ v_1 \f$ (used for x-coordinates)
2896 \param inLastValue_Y iterator pointing behind the last item in the category dataset to use \f$ v_N \f$ (used for x-coordinates)
2897 \param quantile1Spec specifies which quantile to calculate for \a qantile1 (range: 0..1)
2898 \param quantile2Spec specifies which quantile to calculate for \a qantile2 (range: 0..1)
2899 \param minimumQuantile specifies a quantile for the return value minimum (default is 0 for the real minimum, but you could e.g. use 0.05 for the 5% quantile!)
2900 \param maximumQuantile specifies a quantile for the return value maximum (default is 1 for the real maximum, but you could e.g. use 0.95 for the 95% quantile!)
2901 \param groupDefFunc assigns a group \f$ c_{\text{out},j} \f$ to each category value \f$ c_i \f$ .
2902 \param columnBaseName string component used to build the names of the columns generated by this function
2903 \return the boxplot graph
2904
2905
2906
2907 \see jkqtpstatGroupData(), \ref JKQTPlotterBasicJKQTPDatastoreStatisticsGroupedStat
2908*/
2909template <class InputCatIt, class InputValueIt>
2910inline JKQTPBoxplotHorizontalGraph* jkqtpstatVAddBoxplots(JKQTBasePlotter* plotter, InputCatIt inFirstCat_X, InputCatIt inLastCat_X, InputValueIt inFirstValue_Y, InputValueIt inLastValue_Y, double quantile1Spec=0.25, double quantile2Spec=0.75, double minimumQuantile=0, double maximumQuantile=1.0, JKQTPStatGroupDefinitionFunctor1D groupDefFunc=&jkqtpstatGroupingIdentity1D, const QString& columnBaseName=QString("grouped boxplot data")) {
2911
2912 return jkqtpstatAddBoxplots<InputCatIt,InputValueIt,JKQTPBoxplotHorizontalGraph>(plotter, inFirstCat_X, inLastCat_X, inFirstValue_Y, inLastValue_Y, quantile1Spec, quantile2Spec, minimumQuantile, maximumQuantile, groupDefFunc, columnBaseName);
2913}
2914
2915/*! \brief create vertical boxplots of type \c JKQTPBoxplotVerticalGraph, from the 5-value-summary of groups in the input data, also adds a graph showing the outliers
2916 \ingroup jkqtptools_math_statistics_adaptors
2917
2918 \tparam InputCatIt standard iterator type of \a inFirstCat_X and \a inLastCat_X
2919 \tparam InputValueIt standard iterator type of \a inFirstValue_Y and \a inLastValue_Y
2920 \param plotter the plotter to which to add the resulting graph
2921 \param inFirstCat_X iterator pointing to the first item in the category dataset to use \f$ c_1 \f$ (used for y-coordinates)
2922 \param inLastCat_X iterator pointing behind the last item in the category dataset to use \f$ c_N \f$ (used for y-coordinates)
2923 \param inFirstValue_Y iterator pointing to the first item in the category dataset to use \f$ v_1 \f$ (used for x-coordinates)
2924 \param inLastValue_Y iterator pointing behind the last item in the category dataset to use \f$ v_N \f$ (used for x-coordinates)
2925 \param quantile1Spec specifies which quantile to calculate for \a qantile1 (range: 0..1)
2926 \param quantile2Spec specifies which quantile to calculate for \a qantile2 (range: 0..1)
2927 \param minimumQuantile specifies a quantile for the return value minimum (default is 0 for the real minimum, but you could e.g. use 0.05 for the 5% quantile!)
2928 \param maximumQuantile specifies a quantile for the return value maximum (default is 1 for the real maximum, but you could e.g. use 0.95 for the 95% quantile!)
2929 \param groupDefFunc assigns a group \f$ c_{\text{out},j} \f$ to each category value \f$ c_i \f$ .
2930 \param columnBaseName string component used to build the names of the columns generated by this function
2931 \return the boxplot graph (return.first) and the outliers graph (return.second)
2932
2933
2934
2935 \see jkqtpstatGroupData(), \ref JKQTPlotterBasicJKQTPDatastoreStatisticsGroupedStat
2936*/
2937template <class InputCatIt, class InputValueIt>
2938inline std::pair<JKQTPBoxplotVerticalGraph*, JKQTPXYLineGraph*> jkqtpstatAddVBoxplotsAndOutliers(JKQTBasePlotter* plotter, InputCatIt inFirstCat_X, InputCatIt inLastCat_X, InputValueIt inFirstValue_Y, InputValueIt inLastValue_Y, double quantile1Spec=0.25, double quantile2Spec=0.75, double minimumQuantile=0.03, double maximumQuantile=0.97, JKQTPStatGroupDefinitionFunctor1D groupDefFunc=&jkqtpstatGroupingIdentity1D, const QString& columnBaseName=QString("grouped boxplot data")) {
2939 std::map<double, std::vector<double> > groupeddataBar;
2940 jkqtpstatGroupData(inFirstCat_X, inLastCat_X, inFirstValue_Y, inLastValue_Y, groupeddataBar, groupDefFunc);
2941
2942 size_t colGroup=plotter->getDatastore()->addColumn(columnBaseName+", group");
2943 size_t colMin=plotter->getDatastore()->addColumn(columnBaseName+", minimum");
2944 size_t colQ25=plotter->getDatastore()->addColumn(columnBaseName+", quartile25");
2945 size_t colMedian=plotter->getDatastore()->addColumn(columnBaseName+", median");
2946 size_t colIQRSig=plotter->getDatastore()->addColumn(columnBaseName+", MedianSignificance");
2947 size_t colAverage=plotter->getDatastore()->addColumn(columnBaseName+", average");
2948 size_t colQ75=plotter->getDatastore()->addColumn(columnBaseName+", quartile75");
2949 size_t colMax=plotter->getDatastore()->addColumn(columnBaseName+", maximum");
2950 size_t colOutlierG=plotter->getDatastore()->addColumn(columnBaseName+", outlier-group");
2951 size_t colOutlierV=plotter->getDatastore()->addColumn(columnBaseName+", outlier-value");
2952
2953 for (auto it=groupeddataBar.begin(); it!=groupeddataBar.end(); ++it) {
2954
2955 auto stat5=jkqtpstat5NumberStatistics(it->second.begin(), it->second.end(), quantile1Spec, quantile2Spec, minimumQuantile, maximumQuantile);
2956
2957 plotter->getDatastore()->appendToColumn(colGroup, it->first);
2958 plotter->getDatastore()->appendToColumn(colAverage, jkqtpstatAverage(it->second.begin(), it->second.end()));
2959 plotter->getDatastore()->appendToColumn(colMin, stat5.minimum);
2960 plotter->getDatastore()->appendToColumn(colQ25, stat5.quantile1);
2961 plotter->getDatastore()->appendToColumn(colMedian, stat5.median);
2962 plotter->getDatastore()->appendToColumn(colQ75, stat5.quantile2);
2963 plotter->getDatastore()->appendToColumn(colMax, stat5.maximum);
2964 plotter->getDatastore()->appendToColumn(colIQRSig, stat5.IQRSignificanceEstimate());
2965 std::fill_n(plotter->getDatastore()->backInserter(colOutlierG), stat5.outliers.size(), jkqtp_todouble(it->first));
2966 plotter->getDatastore()->appendToColumn(colOutlierV, stat5.outliers.begin(), stat5.outliers.end());
2967 }
2968
2970 plotter->addGraph(graph=new JKQTPBoxplotVerticalGraph(plotter));
2971 graph->setPositionColumn(colGroup);
2972 graph->setMinColumn(colMin);
2973 graph->setMaxColumn(colMax);
2974 graph->setMedianColumn(colMedian);
2975 graph->setMeanColumn(colAverage);
2976 graph->setPercentile25Column(colQ25);
2977 graph->setPercentile75Column(colQ75);
2978 graph->setMedianConfidenceColumn(colIQRSig);
2979
2980 JKQTPXYLineGraph* graphOL;
2981 plotter->addGraph(graphOL=new JKQTPXYLineGraph(plotter));
2982 graphOL->setXColumn(colOutlierG);
2983 graphOL->setYColumn(colOutlierV);
2984 graphOL->setDrawLine(false);
2985 graphOL->setSymbolSize(graphOL->getSymbolSize()/2.0);
2986 graphOL->setColor(graph->getLineColor());
2987 return std::pair<JKQTPBoxplotVerticalGraph*, JKQTPXYLineGraph*>(graph, graphOL);
2988}
2989
2990
2991/*! \brief create vertical boxplots of type \c JKQTPBoxplotHorizontalGraph, from the 5-value-summary of groups in the input data, also adds a graph showing the outliers
2992 \ingroup jkqtptools_math_statistics_adaptors
2993
2994 \tparam InputCatIt standard iterator type of \a inFirstCat_Y and \a inLastCat_Y
2995 \tparam InputValueIt standard iterator type of \a inFirstValue_X and \a inLastValue_X
2996 \param plotter the plotter to which to add the resulting graph
2997 \param inFirstCat_Y iterator pointing to the first item in the category dataset to use \f$ c_1 \f$ (used for y-coordinates)
2998 \param inLastCat_Y iterator pointing behind the last item in the category dataset to use \f$ c_N \f$ (used for y-coordinates)
2999 \param inFirstValue_X iterator pointing to the first item in the category dataset to use \f$ v_1 \f$ (used for x-coordinates)
3000 \param inLastValue_X iterator pointing behind the last item in the category dataset to use \f$ v_N \f$ (used for x-coordinates)
3001 \param quantile1Spec specifies which quantile to calculate for \a qantile1 (range: 0..1)
3002 \param quantile2Spec specifies which quantile to calculate for \a qantile2 (range: 0..1)
3003 \param minimumQuantile specifies a quantile for the return value minimum (default is 0 for the real minimum, but you could e.g. use 0.05 for the 5% quantile!)
3004 \param maximumQuantile specifies a quantile for the return value maximum (default is 1 for the real maximum, but you could e.g. use 0.95 for the 95% quantile!)
3005 \param groupDefFunc assigns a group \f$ c_{\text{out},j} \f$ to each category value \f$ c_i \f$ .
3006 \param columnBaseName string component used to build the names of the columns generated by this function
3007 \return the boxplot graph (return.first) and the outliers graph (return.second)
3008
3009
3010
3011 \see jkqtpstatGroupData(), \ref JKQTPlotterBasicJKQTPDatastoreStatisticsGroupedStat
3012*/
3013template <class InputCatIt, class InputValueIt>
3014inline std::pair<JKQTPBoxplotHorizontalGraph*, JKQTPXYLineGraph*> jkqtpstatAddHBoxplotsAndOutliers(JKQTBasePlotter* plotter, InputCatIt inFirstCat_Y, InputCatIt inLastCat_Y, InputValueIt inFirstValue_X, InputValueIt inLastValue_X, double quantile1Spec=0.25, double quantile2Spec=0.75, double minimumQuantile=0.03, double maximumQuantile=0.97, JKQTPStatGroupDefinitionFunctor1D groupDefFunc=&jkqtpstatGroupingIdentity1D, const QString& columnBaseName=QString("grouped boxplot data")) {
3015 std::map<double, std::vector<double> > groupeddataBar;
3016 jkqtpstatGroupData(inFirstCat_Y, inLastCat_Y, inFirstValue_X, inLastValue_X, groupeddataBar, groupDefFunc);
3017
3018 size_t colGroup=plotter->getDatastore()->addColumn(columnBaseName+", group");
3019 size_t colMin=plotter->getDatastore()->addColumn(columnBaseName+", minimum");
3020 size_t colQ25=plotter->getDatastore()->addColumn(columnBaseName+", quartile25");
3021 size_t colMedian=plotter->getDatastore()->addColumn(columnBaseName+", median");
3022 size_t colIQRSig=plotter->getDatastore()->addColumn(columnBaseName+", MedianSignificance");
3023 size_t colAverage=plotter->getDatastore()->addColumn(columnBaseName+", average");
3024 size_t colQ75=plotter->getDatastore()->addColumn(columnBaseName+", quartile75");
3025 size_t colMax=plotter->getDatastore()->addColumn(columnBaseName+", maximum");
3026 size_t colOutlierG=plotter->getDatastore()->addColumn(columnBaseName+", outlier-group");
3027 size_t colOutlierV=plotter->getDatastore()->addColumn(columnBaseName+", outlier-value");
3028
3029 for (auto it=groupeddataBar.begin(); it!=groupeddataBar.end(); ++it) {
3030
3031 auto stat5=jkqtpstat5NumberStatistics(it->second.begin(), it->second.end(), quantile1Spec, quantile2Spec, minimumQuantile, maximumQuantile);
3032
3033 plotter->getDatastore()->appendToColumn(colGroup, it->first);
3034 plotter->getDatastore()->appendToColumn(colAverage, jkqtpstatAverage(it->second.begin(), it->second.end()));
3035 plotter->getDatastore()->appendToColumn(colMin, stat5.minimum);
3036 plotter->getDatastore()->appendToColumn(colQ25, stat5.quantile1);
3037 plotter->getDatastore()->appendToColumn(colMedian, stat5.median);
3038 plotter->getDatastore()->appendToColumn(colQ75, stat5.quantile2);
3039 plotter->getDatastore()->appendToColumn(colMax, stat5.maximum);
3040 plotter->getDatastore()->appendToColumn(colIQRSig, stat5.IQRSignificanceEstimate());
3041 std::fill_n(plotter->getDatastore()->backInserter(colOutlierG), stat5.outliers.size(), jkqtp_todouble(it->first));
3042 plotter->getDatastore()->appendToColumn(colOutlierV, stat5.outliers.begin(), stat5.outliers.end());
3043 }
3044
3046 plotter->addGraph(graph=new JKQTPBoxplotHorizontalGraph(plotter));
3047 graph->setPositionColumn(colGroup);
3048 graph->setMinColumn(colMin);
3049 graph->setMaxColumn(colMax);
3050 graph->setMedianColumn(colMedian);
3051 graph->setMeanColumn(colAverage);
3052 graph->setPercentile25Column(colQ25);
3053 graph->setPercentile75Column(colQ75);
3054 graph->setMedianConfidenceColumn(colIQRSig);
3055
3056 JKQTPXYLineGraph* graphOL;
3057 plotter->addGraph(graphOL=new JKQTPXYLineGraph(plotter));
3058 graphOL->setYColumn(colOutlierG);
3059 graphOL->setXColumn(colOutlierV);
3060 graphOL->setDrawLine(false);
3061 graphOL->setSymbolSize(graphOL->getSymbolSize()/2.0);
3062 graphOL->setColor(graph->getLineColor());
3063 return std::pair<JKQTPBoxplotHorizontalGraph*, JKQTPXYLineGraph*>(graph, graphOL);
3064}
3065
3066
3067
3068
3069
3070
3071#endif // JKQTPGRAPHSSTATISTICSADAPTORS_H_INCLUDED
base class for 2D plotter classes (used by the plotter widget JKQTPlotter)
Definition jkqtpbaseplotter.h:394
size_t addGraph(JKQTPPlotElement *gr)
Definition jkqtpbaseplotter.h:566
JKQTPDatastore * getDatastore()
returns a pointer to the datastore used by this object
Definition jkqtpbaseplotter.h:449
This implements a horizontal bar graph with bars between and and error indicator.
Definition jkqtpbarchart.h:202
This implements a horizontal bar graph with bars between and .
Definition jkqtpbarchart.h:155
This implements a vertical bar graph with bars between and and error indicator.
Definition jkqtpbarchart.h:90
This implements a vertical bar graph with bars between and .
Definition jkqtpbarchart.h:51
void setMin(double __value)
the minimum value to be used for the boxplot
void setMedianConfidenceIntervalWidth(double __value)
the width of the confidence interval around the median
void setDrawMean(bool __value)
indicates whether to draw the mean
void setPos(double __value)
the position of the boxplot on the "other" axis
void setDrawMedian(bool __value)
indicates whether to draw the median
void setMedian(double __value)
the median value to be used for the boxplot
void setMax(double __value)
the maximum value to be used for the boxplot
void setDrawMinMax(bool __value)
indicates whether to draw the percentiles
virtual QColor getKeyLabelColor() const override
returns the color to be used for the key label
void setMean(double __value)
the mean value to be used for the boxplot
void setDrawNotch(bool __value)
indicates whether to draw a notch with width medianConfidenceIntervalWidth
void setPercentile75(double __value)
the 75% percentile value to be used for the boxplot
void setPercentile25(double __value)
the 25% percentile value to be used for the boxplot
void setMedianConfidenceColumn(size_t __value)
the column that contains the confidence interval width of the median (e.g. 1.57*IQR/sqrt(n) )....
void setPercentile25Column(int __value)
the column that contains the 25% percentile-component of the datapoints
void setMinColumn(int __value)
the column that contains the minimum-component of the datapoints
void setPositionColumn(int __value)
the column that contains the x-component of the datapoints
void setMedianColumn(int __value)
the column that contains the median-component of the datapoints
void setMeanColumn(int __value)
the column that contains the median-component of the datapoints.
void setMaxColumn(int __value)
the column that contains the maximum-component of the datapoints
void setPercentile75Column(int __value)
the column that contains the 75% percentile-component of the datapoints
This implements a horizontal (notched) boxplot where the data is directly given to the object and not...
Definition jkqtpboxplot.h:229
This implements horizontal boxplots, optionally also a notched boxplot.
Definition jkqtpboxplot.h:140
This implements a single vertical (notched) boxplot as a "geometric element", where the data is direc...
Definition jkqtpboxplot.h:188
This implements vertical boxplots, optionally also a notched boxplot.
Definition jkqtpboxplot.h:102
class for a contour plots (same as JKQTPContourPlot) of images stored in a JKQTPDatastore column
Definition jkqtpcontour.h:253
void setImageColumn(int __value)
column containing the displayed image
class to plot an image from an 2-dimensional array of values stored in a column of the datastore
Definition jkqtpimage.h:771
virtual void setImageColumn(int __value)
column containing the displayed image
void createContourLevels(int nLevels=3)
creates at nLevels contour levels linearly spaced between the data's minimum and maximum values
This class manages data columns (with entries of type double ), used by JKQTPlotter/JKQTBasePlotter t...
Definition jkqtpdatastorage.h:282
JKQTPColumnBackInserter backInserter(int i)
returns a back-inserter iterator (JKQTPColumnBackInserter) to the i -th column in the JKQTPDatastore
void appendToColumn(size_t column, double value)
adds a value value to the column column. This changes the column length (number of rows).
size_t addImageColumn(size_t width, size_t height, const QString &name=QString(""))
add a new columns with width * height rows to the datastore and return its column ID....
size_t addCopiedColumn(TIterator first, TIterator last, const QString &name=QString(""))
add one column to the datastore. It will be filled with the values from first ... last
Definition jkqtpdatastorage.h:871
ColumnIterator begin()
returns an iterator to the first column in the JKQTPDatastore
ColumnIterator end()
returns an iterator behind the last column in the JKQTPDatastore
size_t addColumn(JKQTPColumn col)
add a new column to the datastore and return its ID
void setParamsV(double p1)
set an internal parameter vector as function parameters, initialized with {p1}
This implements filled curve plots with y errors where the area is filled between the plot line and t...
Definition jkqtpfilledcurve.h:131
This implements filled curve plots with y errors where the area is filled between the plot line and t...
Definition jkqtpfilledcurve.h:244
virtual void setPlotFunctionFunctor(jkqtpPlotFunctionType &&__value)
sets a functor to be plotted
void setSpecialFunction(SpecialFunction function)
sets function to the given special function
@ Line
a polynomial The parameters params have to be point to a QVector<double> and contain the parameters
Definition jkqtpevaluatedfunction.h:172
void setDrawBox(bool __value)
enables/disables drawing of the actual box of the boxplot (false leads to Tufte Style boxplots )
QColor getLineColor() const
get the color of the graph line
double getSymbolSize() const
get the size (=diameter in pt) of the graph symbol (in pt)
void setSymbolSize(double __value)
set the size (=diameter in pt) of the graph symbol (in pt)
void setSymbolType(JKQTPGraphSymbols __value)
set the type of the graph symbol
@ StepViolin
connect violin points by a steped line, but fully filled
Definition jkqtpviolinplotstylingmixins.h:305
void setViolinStyle(ViolinStyle style)
set the style of the violin plot
void setHeight(double __value)
height of image
void setX(double __value)
x coordinate of lower left corner
void setWidth(double __value)
width of image
void setY(double __value)
y coordinate of lower left corner
This implements an impulse plot with horizontal impulses in direction of the X axis (i....
Definition jkqtpimpulses.h:152
This implements an impulse plot with impulses in direction of the X axis (i.e. from x=0 to x=f(y) )
Definition jkqtpimpulses.h:232
virtual void setTitle(const QString &title) override
sets the title of the plot (for display in key!).
virtual void setTitle(const QString &__value)
sets the title of the plot (for display in key!).
const JKQTBasePlotter * getParent() const
returns the parent painter class
Definition jkqtpgraphsbase.h:112
void setDataColumn(int __value)
the column that contains the datapoints
@ X
the data for a JKQTPSingleColumnGraph is data belonging to the x-axis of the plot
@ Y
the data for a JKQTPSingleColumnGraph is data belonging to the y-axis of the plot
void setDataDirection(DataDirection __value)
interpret the data from dataColumn either as X- or Y-data
plots a 1-column set of data-values with symbols onto a JKQtPlotter/JKQtBasePlotter....
Definition jkqtpsinglecolumnsymbols.h:53
@ NoScatter
missing coordinate is exactly position for every datapoint in dataColumn
Definition jkqtpsinglecolumnsymbols.h:58
void setColor(QColor col)
set symbol color and fill color at the same time
void setPosition(double __value)
missing coordinate, i.e. if the data from dataColumn is interpreted as x-values, this is the y-positi...
void setPositionScatterStyle(ScatterStyle __value)
how to distribute the datapoints from dataColumn at the location position
void setDrawMedian(bool __value)
indicates whether to draw the median
void setDrawMinMax(bool __value)
indicates whether to draw the percentiles
virtual QColor getKeyLabelColor() const override
returns the color to be used for the key label
void setMax(double __value)
the maximum value to be used for the boxplot
void setPos(double __value)
the position of the boxplot on the "other" axis
void setViolinPositionColumn(int __value)
column with data for the violin outline: category values (along min-max-axis)
void setMin(double __value)
the minimum value to be used for the boxplot
void setDrawMean(bool __value)
indicates whether to draw the mean
void setMedian(double __value)
the median value to be used for the boxplot
void setMean(double __value)
the mean value to be used for the boxplot
void setViolinFrequencyColumn(int __value)
column with data for the violin outline: frequency values (perpendicular to min-max-axis)
This implements a single horizontal Violin Plot as a "geometric element".
Definition jkqtpviolinplot.h:216
This implements a single vertical Violin Plot as a "geometric element".
Definition jkqtpviolinplot.h:166
This implements line plots where the data is taken from a user supplied function .
Definition jkqtpevaluatedfunction.h:289
This virtual JKQTPGraph descendent may be used as base for all graphs that use at least two columns t...
Definition jkqtpgraphsbase.h:586
void setYColumn(int __value)
the column that contains the y-component of the datapoints
void setXColumn(int __value)
the column that contains the x-component of the datapoints
int getXColumn() const
the column that contains the x-component of the datapoints
int getYColumn() const
the column that contains the y-component of the datapoints
This implements xy line plots with x and y error indicators.
Definition jkqtplines.h:112
This implements xy line plots. This also alows to draw symbols at the data points.
Definition jkqtplines.h:61
void setDrawLine(bool __value)
indicates whether to draw a line or not
void setColor(QColor c)
set color of line and symbol
This implements xy scatter plots (like JKQTPXYScatterGraph), but the color and size of the symbols ma...
Definition jkqtpscatter.h:431
#define JKQTPLOTTER_LIB_EXPORT
Definition jkqtplotter_imexport.h:89
#define JKQTPASSERT_M(condition, message)
dynamic assertion, throws an exception with the given message, when the given condition condition eva...
Definition jkqtpdebuggingtools.h:73
@ JKQTPNoSymbol
plots no symbol at all (usefull together with error bars)
Definition jkqtpdrawingtools.h:144
QString jkqtp_polynomialModel2Latex(PolyItP firstP, PolyItP lastP)
Generates a LaTeX string for the polynomial model with the coefficients firstP ......
Definition jkqtpmathtools.h:578
constexpr double jkqtp_todouble(const T &d)
converts a boolean to a double, is used to convert boolean to double by JKQTPDatastore
Definition jkqtpmathtools.h:113
std::function< double(double)> jkqtp_generatePolynomialModel(PolyItP firstP, PolyItP lastP)
returns a C++-functor, which evaluates a polynomial
Definition jkqtpmathtools.h:566
void jkqtpstatHistogram1D(InputIt first, InputIt last, BinsInputIt binsFirst, BinsInputIt binsLast, OutputIt histogramXOut, OutputIt histogramYOut, bool normalized=true, bool cummulative=false, JKQTPStatHistogramBinXMode binXMode=JKQTPStatHistogramBinXMode::XIsLeft)
calculate an autoranged 1-dimensional histogram from the given data range first .....
Definition jkqtpstathistogram.h:205
void jkqtpstatHistogram1DAutoranged(InputIt first, InputIt last, OutputIt histogramXOut, OutputIt histogramYOut, int bins=11, bool normalized=true, bool cummulative=false, JKQTPStatHistogramBinXMode binXMode=JKQTPStatHistogramBinXMode::XIsLeft)
calculate an autoranged 1-dimensional histogram from the given data range first .....
Definition jkqtpstathistogram.h:73
@ XIsMid
x-location is the middle of the bin
double jkqtpstatKernel1DGaussian(double t)
a 1D Gaussian kernel function, e.g. for Kernel Density Estimation
Definition jkqtpstatkde.h:52
void jkqtpstatKDE1DAutoranged(InputIt first, InputIt last, OutputIt KDEXOut, OutputIt KDEYOut, int Nout=100, const std::function< double(double)> &kernel=std::function< double(double)>(&jkqtpstatKernel1DGaussian), double bandwidth=1.0, bool cummulative=false)
calculate an autoranged 1-dimensional Kernel Density Estimation (KDE) from the given data range first...
Definition jkqtpstatkde.h:255
double jkqtpstatEstimateKDEBandwidth(InputIt first, InputIt last)
estimates a bandwidth for a Kernel Density Estimator (KDE) of the given data first ....
Definition jkqtpstatkde.h:192
void jkqtpstatKDE1D(InputIt first, InputIt last, BinsInputIt binsFirst, BinsInputIt binsLast, OutputIt KDEXOut, OutputIt KDEYOut, const std::function< double(double)> &kernel=std::function< double(double)>(&jkqtpstatKernel1DGaussian), double bandwidth=1.0, bool cummulative=false)
calculate an autoranged 1-dimensional Kernel Density Estimation (KDE) from the given data range first...
Definition jkqtpstatkde.h:368
void jkqtpstatHistogram2D(InputItX firstX, InputItX lastX, InputItY firstY, InputItY lastY, OutputIt histogramImgOut, double xmin, double xmax, double ymin, double ymax, size_t xbins=10, size_t ybins=10, bool normalized=true)
calculate a 2-dimensional histogram from the given data range firstX / firstY ... lastY / lastY
Definition jkqtpstathistogram.h:287
double jkqtpstatKernel2DGaussian(double tx, double ty)
a 2D Gaussian kernel function, e.g. for Kernel Density Estimation
Definition jkqtpstatkde.h:148
void jkqtpstatKDE2D(InputItX firstX, InputItX lastX, InputItY firstY, InputItY lastY, OutputIt histogramImgOut, double xmin, double xmax, double ymin, double ymax, size_t xbins, size_t ybins, const std::function< double(double, double)> &kernel=std::function< double(double, double)>(&jkqtpstatKernel2DGaussian), double bandwidthX=1.0, double bandwidthY=1.0)
calculate an autoranged 2-dimensional Kernel Density Estimation (KDE) from the given data range first...
Definition jkqtpstatkde.h:566
JKQTPColumnMathImage * jkqtpstatAddHistogram2DImage(JKQTBasePlotter *plotter, InputItX firstX, InputItX lastX, InputItY firstY, InputItY lastY, size_t xbins=10, size_t ybins=10, bool normalized=true, const QString &histogramcolumnBaseName=QString("histogram"), double *oxmin=nullptr, double *oxmax=nullptr, double *oymin=nullptr, double *oymax=nullptr)
calculate calculate a 2-dimensional histogram and add a JKQTPColumnMathImage to the given plotter,...
Definition jkqtpstatisticsadaptors.h:1059
std::pair< JKQTPViolinplotHorizontalElement *, JKQTPSingleColumnSymbolsGraph * > jkqtpstatAddHViolinplotKDEAndOutliers(JKQTBasePlotter *plotter, InputIt first, InputIt last, double violinposY, const std::function< double(double)> &kernel=std::function< double(double)>(&jkqtpstatKernel1DGaussian), double bandwidth=-1, double minimumQuantile=0.03, double maximumQuantile=0.97, const QString &distBasename=QString("violin plot distribution"), int violinDistSamples=100)
add a JKQTPViolinplotHorizontalElement and an outliers graph to the given plotter,...
Definition jkqtpstatisticsadaptors.h:490
std::pair< JKQTPViolinplotVerticalElement *, JKQTPSingleColumnSymbolsGraph * > jkqtpstatAddVViolinplotHistogramAndOutliers(JKQTBasePlotter *plotter, InputIt first, InputIt last, double violinposY, double minimumQuantile=0.03, double maximumQuantile=0.97, const QString &distBasename=QString("violin plot distribution"), int violinDistSamples=21)
add a JKQTPViolinplotVerticalElement and an outliers graph to the given plotter, where the Violinplot...
Definition jkqtpstatisticsadaptors.h:744
JKQTPBarHorizontalGraph * jkqtpstatAddVHistogram1D(JKQTBasePlotter *plotter, InputIt first, InputIt last, BinsInputIt binsFirst, BinsInputIt binsLast, bool normalized=true, bool cummulative=false, const QString &histogramcolumnBaseName=QString("histogram"))
calculate an autoranged histogram and add a JKQTPBarHorizontalGraph to the given plotter,...
Definition jkqtpstatisticsadaptors.h:1015
JKQTPXYParametrizedErrorScatterGraph * jkqtpstatAddXYErrorParametrizedScatterGraph(JKQTBasePlotter *plotter, InputCatIt inFirstCat_X, InputCatIt inLastCat_X, InputValueIt inFirstValue_Y, InputValueIt inLastValue_Y, JKQTPStatGroupDefinitionFunctor1D groupDefFunc=&jkqtpstatGroupingIdentity1D, const QString &columnBaseName=QString("grouped data"))
create a JKQTPXYParametrizedErrorScatterGraph with y-direction error bars, calculated from average +/...
Definition jkqtpstatisticsadaptors.h:2782
JKQTPImpulsesHorizontalErrorGraph * jkqtpstatAddXErrorImpulsesGraph(JKQTBasePlotter *plotter, InputCatIt inFirstCat_Y, InputCatIt inLastCat_Y, InputValueIt inFirstValue_Y, InputValueIt inLastValue_Y, JKQTPStatGroupDefinitionFunctor1D groupDefFunc=&jkqtpstatGroupingIdentity1D, const QString &columnBaseName=QString("grouped data"))
create a JKQTPImpulsesHorizontalErrorGraph with x-direction error bars, calculated from average +/- s...
Definition jkqtpstatisticsadaptors.h:2629
JKQTPColumnMathImage * jkqtpstatAddKDE2DImage(JKQTBasePlotter *plotter, InputItX firstX, InputItX lastX, InputItY firstY, InputItY lastY, size_t xbins=10, size_t ybins=10, const std::function< double(double, double)> &kernel=std::function< double(double, double)>(&jkqtpstatKernel2DGaussian), double bandwidthX=1.0, double bandwidthY=1.0, const QString &kdecolumnBaseName=QString("histogram"), double *oxmin=nullptr, double *oxmax=nullptr, double *oymin=nullptr, double *oymax=nullptr)
calculate calculate a 2-dimensional kernel density estimate (KDE) and add a JKQTPColumnMathImage to t...
Definition jkqtpstatisticsadaptors.h:1640
std::pair< JKQTPBoxplotVerticalGraph *, JKQTPXYLineGraph * > jkqtpstatAddVBoxplotsAndOutliers(JKQTBasePlotter *plotter, InputCatIt inFirstCat_X, InputCatIt inLastCat_X, InputValueIt inFirstValue_Y, InputValueIt inLastValue_Y, double quantile1Spec=0.25, double quantile2Spec=0.75, double minimumQuantile=0.03, double maximumQuantile=0.97, JKQTPStatGroupDefinitionFunctor1D groupDefFunc=&jkqtpstatGroupingIdentity1D, const QString &columnBaseName=QString("grouped boxplot data"))
create vertical boxplots of type JKQTPBoxplotVerticalGraph, from the 5-value-summary of groups in the...
Definition jkqtpstatisticsadaptors.h:2938
JKQTPFilledCurveYErrorGraph * jkqtpstatAddYErrorFilledCurveGraph(JKQTBasePlotter *plotter, InputCatIt inFirstCat_X, InputCatIt inLastCat_X, InputValueIt inFirstValue_Y, InputValueIt inLastValue_Y, JKQTPStatGroupDefinitionFunctor1D groupDefFunc=&jkqtpstatGroupingIdentity1D, const QString &columnBaseName=QString("grouped data"))
create a JKQTPFilledCurveYErrorGraph with y-direction error bars, calculated from average +/- stddev ...
Definition jkqtpstatisticsadaptors.h:2507
JKQTPBarVerticalGraph * jkqtpstatAddHHistogram1D(JKQTBasePlotter *plotter, InputIt first, InputIt last, BinsInputIt binsFirst, BinsInputIt binsLast, bool normalized=true, bool cummulative=false, const QString &histogramcolumnBaseName=QString("histogram"))
calculate an autoranged histogram and add a JKQTPBarVerticalGraph to the given plotter,...
Definition jkqtpstatisticsadaptors.h:906
TGraph * jkqtpstatAddXErrorGraph(JKQTBasePlotter *plotter, InputCatIt inFirstCat_Y, InputCatIt inLastCat_Y, InputValueIt inFirstValue_Y, InputValueIt inLastValue_Y, JKQTPStatGroupDefinitionFunctor1D groupDefFunc=&jkqtpstatGroupingIdentity1D, const QString &columnBaseName=QString("grouped data"))
create a plot with x-direction error bars, calculated from average +/- stddev of groups in the input ...
Definition jkqtpstatisticsadaptors.h:2537
TGraph * jkqtpstatAddXYErrorGraph(JKQTBasePlotter *plotter, InputCatIt inFirstCat_X, InputCatIt inLastCat_X, InputValueIt inFirstValue_Y, InputValueIt inLastValue_Y, JKQTPStatGroupDefinitionFunctor1D groupDefFunc=&jkqtpstatGroupingIdentity1D, const QString &columnBaseName=QString("grouped data"))
create a plot with x- and y-direction error bars, calculated from directional average +/- stddev of g...
Definition jkqtpstatisticsadaptors.h:2708
JKQTPXFunctionLineGraph * jkqtpstatAddRobustIRLSRegression(JKQTBasePlotter *plotter, JKQTPStatRegressionModelType type, InputItX firstX, InputItX lastX, InputItY firstY, InputItY lastY, double *coeffA=nullptr, double *coeffB=nullptr, bool fixA=false, bool fixB=false, double p=1.1, int iterations=100)
calculate the (robust) iteratively reweighted least-squares (IRLS) estimate for the parameters where ...
Definition jkqtpstatisticsadaptors.h:2080
JKQTPBarHorizontalGraph * jkqtpstatAddVHistogram1DAutoranged(JKQTBasePlotter *plotter, InputIt first, InputIt last, int bins=11, bool normalized=true, bool cummulative=false, const QString &histogramcolumnBaseName=QString("histogram"))
calculate an autoranged histogram and add a JKQTPBarHorizontalGraph to the given plotter,...
Definition jkqtpstatisticsadaptors.h:941
JKQTPXYLineGraph * jkqtpstatAddVKDE1DAutoranged(JKQTBasePlotter *plotter, InputIt first, InputIt last, int Nout=100, const std::function< double(double)> &kernel=std::function< double(double)>(&jkqtpstatKernel1DGaussian), double bandwidth=1.0, bool cummulative=false, const QString &KDEcolumnBaseName=QString("KDE"))
calculate an autoranged vertical KDE and add a JKQTPXYLineGraph to the given plotter,...
Definition jkqtpstatisticsadaptors.h:1457
JKQTPViolinplotHorizontalElement * jkqtpstatAddHViolinplotHistogram(JKQTBasePlotter *plotter, InputIt first, InputIt last, double violinposY, const QString &distBasename=QString("violin plot distribution"), int violinDistSamples=21)
add a JKQTPViolinplotHorizontalElement to the given plotter, where the Violinplot values are calculat...
Definition jkqtpstatisticsadaptors.h:334
JKQTPViolinplotVerticalElement * jkqtpstatAddVViolinplotKDE(JKQTBasePlotter *plotter, InputIt first, InputIt last, double violinposY, const std::function< double(double)> &kernel=std::function< double(double)>(&jkqtpstatKernel1DGaussian), double bandwidth=-1, const QString &distBasename=QString("violin plot distribution"), int violinDistSamples=100)
add a JKQTPViolinplotVerticalElement to the given plotter, where the Violinplot values are calculated...
Definition jkqtpstatisticsadaptors.h:384
std::pair< JKQTPBoxplotVerticalElement *, JKQTPSingleColumnSymbolsGraph * > jkqtpstatAddVBoxplotAndOutliers(JKQTBasePlotter *plotter, InputIt first, InputIt last, double boxposX, double quantile1Spec=0.25, double quantile2Spec=0.75, double minimumQuantile=0.03, double maximumQuantile=0.97, const QString &outliercolumnBaseName=QString("boxplot"), JKQTPStat5NumberStatistics *statOutput=nullptr)
add a JKQTPBoxplotVerticalElement and a JKQTPSingleColumnSymbolsGraph for outliers to the given plott...
Definition jkqtpstatisticsadaptors.h:224
std::pair< JKQTPBoxplotHorizontalGraph *, JKQTPXYLineGraph * > jkqtpstatAddHBoxplotsAndOutliers(JKQTBasePlotter *plotter, InputCatIt inFirstCat_Y, InputCatIt inLastCat_Y, InputValueIt inFirstValue_X, InputValueIt inLastValue_X, double quantile1Spec=0.25, double quantile2Spec=0.75, double minimumQuantile=0.03, double maximumQuantile=0.97, JKQTPStatGroupDefinitionFunctor1D groupDefFunc=&jkqtpstatGroupingIdentity1D, const QString &columnBaseName=QString("grouped boxplot data"))
create vertical boxplots of type JKQTPBoxplotHorizontalGraph, from the 5-value-summary of groups in t...
Definition jkqtpstatisticsadaptors.h:3014
JKQTPViolinplotHorizontalElement * jkqtpstatAddHViolinplotKDE(JKQTBasePlotter *plotter, InputIt first, InputIt last, double violinposY, const std::function< double(double)> &kernel=std::function< double(double)>(&jkqtpstatKernel1DGaussian), double bandwidth=-1, const QString &distBasename=QString("violin plot distribution"), int violinDistSamples=100)
add a JKQTPViolinplotHorizontalElement to the given plotter, where the Violinplot values are calculat...
Definition jkqtpstatisticsadaptors.h:286
JKQTPXYLineErrorGraph * jkqtpstatAddYErrorLineGraph(JKQTBasePlotter *plotter, InputCatIt inFirstCat_X, InputCatIt inLastCat_X, InputValueIt inFirstValue_Y, InputValueIt inLastValue_Y, JKQTPStatGroupDefinitionFunctor1D groupDefFunc=&jkqtpstatGroupingIdentity1D, const QString &columnBaseName=QString("grouped data"))
create a JKQTPXYLineErrorGraph with y-direction error bars, calculated from average +/- stddev of gro...
Definition jkqtpstatisticsadaptors.h:2411
JKQTPXYLineGraph * jkqtpstatAddHKDE1D(JKQTBasePlotter *plotter, InputIt first, InputIt last, BinsInputIt binsFirst, BinsInputIt binsLast, const std::function< double(double)> &kernel=std::function< double(double)>(&jkqtpstatKernel1DGaussian), double bandwidth=1.0, bool cummulative=false, const QString &KDEcolumnBaseName=QString("KDE"))
calculate an autoranged KDE and add a JKQTPXYLineGraph to the given plotter, where the KDE is calcula...
Definition jkqtpstatisticsadaptors.h:1365
JKQTPXYParametrizedErrorScatterGraph * jkqtpstatAddXErrorParametrizedScatterGraph(JKQTBasePlotter *plotter, InputCatIt inFirstCat_Y, InputCatIt inLastCat_Y, InputValueIt inFirstValue_Y, InputValueIt inLastValue_Y, JKQTPStatGroupDefinitionFunctor1D groupDefFunc=&jkqtpstatGroupingIdentity1D, const QString &columnBaseName=QString("grouped data"))
create a JKQTPXYParametrizedErrorScatterGraph with x-direction error bars, calculated from average +/...
Definition jkqtpstatisticsadaptors.h:2653
JKQTPXYParametrizedErrorScatterGraph * jkqtpstatAddYErrorParametrizedScatterGraph(JKQTBasePlotter *plotter, InputCatIt inFirstCat_X, InputCatIt inLastCat_X, InputValueIt inFirstValue_Y, InputValueIt inLastValue_Y, JKQTPStatGroupDefinitionFunctor1D groupDefFunc=&jkqtpstatGroupingIdentity1D, const QString &columnBaseName=QString("grouped data"))
create a JKQTPXYParametrizedErrorScatterGraph with y-direction error bars, calculated from average +/...
Definition jkqtpstatisticsadaptors.h:2483
JKQTPColumnContourPlot * jkqtpstatAddKDE2DContour(JKQTBasePlotter *plotter, InputItX firstX, InputItX lastX, InputItY firstY, InputItY lastY, size_t xbins=10, size_t ybins=10, const std::function< double(double, double)> &kernel=std::function< double(double, double)>(&jkqtpstatKernel2DGaussian), double bandwidthX=1.0, double bandwidthY=1.0, const QString &kdecolumnBaseName=QString("histogram"), double *oxmin=nullptr, double *oxmax=nullptr, double *oymin=nullptr, double *oymax=nullptr)
calculate calculate a 2-dimensional kernel density estimate (KDE) and add a JKQTPColumnContourPlot to...
Definition jkqtpstatisticsadaptors.h:1697
JKQTPViolinplotVerticalElement * jkqtpstatAddVViolinplotHistogram(JKQTBasePlotter *plotter, InputIt first, InputIt last, double violinposY, const QString &distBasename=QString("violin plot distribution"), int violinDistSamples=21)
add a JKQTPViolinplotVerticalElement to the given plotter, where the Violinplot values are calculated...
Definition jkqtpstatisticsadaptors.h:432
std::pair< JKQTPViolinplotVerticalElement *, JKQTPSingleColumnSymbolsGraph * > jkqtpstatAddVViolinplotKDEAndOutliers(JKQTBasePlotter *plotter, InputIt first, InputIt last, double violinposY, const std::function< double(double)> &kernel=std::function< double(double)>(&jkqtpstatKernel1DGaussian), double bandwidth=-1, double minimumQuantile=0.03, double maximumQuantile=0.97, const QString &distBasename=QString("violin plot distribution"), int violinDistSamples=100)
add a JKQTPViolinplotVerticalElement and an outliers graph to the given plotter, where the Violinplot...
Definition jkqtpstatisticsadaptors.h:661
JKQTPBoxplotVerticalElement * jkqtpstatAddVBoxplot(JKQTBasePlotter *plotter, InputIt first, InputIt last, double boxposX, double quantile1Spec=0.25, double quantile2Spec=0.75, double minimumQuantile=0, double maximumQuantile=1.0, JKQTPStat5NumberStatistics *statOutput=nullptr)
add a JKQTPBoxplotVerticalElement to the given plotter, where the boxplot values are calculated from ...
Definition jkqtpstatisticsadaptors.h:112
JKQTPXFunctionLineGraph * jkqtpstatAddPolyFit(JKQTBasePlotter *plotter, InputItX firstX, InputItX lastX, InputItY firstY, InputItY lastY, size_t P, OutputItP firstRes)
fits (in a least-squares sense) a polynomial of order P to a set of N data pairs from a given data ...
Definition jkqtpstatisticsadaptors.h:2248
std::pair< JKQTPViolinplotHorizontalElement *, JKQTPSingleColumnSymbolsGraph * > jkqtpstatAddHViolinplotHistogramAndOutliers(JKQTBasePlotter *plotter, InputIt first, InputIt last, double violinposY, double minimumQuantile=0.03, double maximumQuantile=0.97, const QString &distBasename=QString("violin plot distribution"), int violinDistSamples=21)
add a JKQTPViolinplotHorizontalElement and an outliers graph to the given plotter,...
Definition jkqtpstatisticsadaptors.h:573
JKQTPXFunctionLineGraph * jkqtpstatAddLinearRegression(JKQTBasePlotter *plotter, InputItX firstX, InputItX lastX, InputItY firstY, InputItY lastY, double *coeffA=nullptr, double *coeffB=nullptr, bool fixA=false, bool fixB=false)
calculate the linear regression coefficients for a given data range firstX / firstY ....
Definition jkqtpstatisticsadaptors.h:1754
JKQTPXYLineErrorGraph * jkqtpstatAddXYErrorLineGraph(JKQTBasePlotter *plotter, InputCatIt inFirstCat_X, InputCatIt inLastCat_X, InputValueIt inFirstValue_Y, InputValueIt inLastValue_Y, JKQTPStatGroupDefinitionFunctor1D groupDefFunc=&jkqtpstatGroupingIdentity1D, const QString &columnBaseName=QString("grouped data"))
create a JKQTPXYLineErrorGraph with y-direction error bars, calculated from average +/- stddev of gro...
Definition jkqtpstatisticsadaptors.h:2757
JKQTPBarVerticalGraph * jkqtpstatAddHHistogram1DAutoranged(JKQTBasePlotter *plotter, InputIt first, InputIt last, int bins=11, bool normalized=true, bool cummulative=false, const QString &histogramcolumnBaseName=QString("histogram"))
calculate an autoranged histogram and add a JKQTPBarVerticalGraph to the given plotter,...
Definition jkqtpstatisticsadaptors.h:828
JKQTPXFunctionLineGraph * jkqtpstatAddRobustIRLSLinearRegression(JKQTBasePlotter *plotter, InputItX firstX, InputItX lastX, InputItY firstY, InputItY lastY, double *coeffA=nullptr, double *coeffB=nullptr, bool fixA=false, bool fixB=false, double p=1.1, int iterations=100)
calculate the (robust) iteratively reweighted least-squares (IRLS) estimate for the parameters of the...
Definition jkqtpstatisticsadaptors.h:1830
JKQTPXYLineGraph * jkqtpstatAddVKDE1D(JKQTBasePlotter *plotter, InputIt first, InputIt last, BinsInputIt binsFirst, BinsInputIt binsLast, const std::function< double(double)> &kernel=std::function< double(double)>(&jkqtpstatKernel1DGaussian), double bandwidth=1.0, bool cummulative=false, const QString &KDEcolumnBaseName=QString("KDE"))
calculate an autoranged vertical KDE and add a JKQTPXYLineGraph to the given plotter,...
Definition jkqtpstatisticsadaptors.h:1543
JKQTPXYLineGraph * jkqtpstatAddHKDE1DAutoranged(JKQTBasePlotter *plotter, InputIt first, InputIt last, int Nout=100, const std::function< double(double)> &kernel=std::function< double(double)>(&jkqtpstatKernel1DGaussian), double bandwidth=1.0, bool cummulative=false, const QString &KDEcolumnBaseName=QString("KDE"))
calculate an autoranged KDE and add a JKQTPXYLineGraph to the given plotter, where the KDE is calcula...
Definition jkqtpstatisticsadaptors.h:1279
JKQTPBarVerticalErrorGraph * jkqtpstatAddYErrorBarGraph(JKQTBasePlotter *plotter, InputCatIt inFirstCat_X, InputCatIt inLastCat_X, InputValueIt inFirstValue_Y, InputValueIt inLastValue_Y, JKQTPStatGroupDefinitionFunctor1D groupDefFunc=&jkqtpstatGroupingIdentity1D, const QString &columnBaseName=QString("grouped data"))
create a JKQTPBarVerticalErrorGraph with y-direction error bars, calculated from average +/- stddev o...
Definition jkqtpstatisticsadaptors.h:2435
std::pair< JKQTPBoxplotHorizontalElement *, JKQTPSingleColumnSymbolsGraph * > jkqtpstatAddHBoxplotAndOutliers(JKQTBasePlotter *plotter, InputIt first, InputIt last, double boxposY, double quantile1Spec=0.25, double quantile2Spec=0.75, double minimumQuantile=0.03, double maximumQuantile=0.97, const QString &outliercolumnBaseName=QString("boxplot"), JKQTPStat5NumberStatistics *statOutput=nullptr)
add a JKQTPBoxplotHorizontalElement and a JKQTPSingleColumnSymbolsGraph for outliers to the given plo...
Definition jkqtpstatisticsadaptors.h:164
JKQTPFilledCurveXErrorGraph * jkqtpstatAddXErrorFilledCurveGraph(JKQTBasePlotter *plotter, InputCatIt inFirstCat_Y, InputCatIt inLastCat_Y, InputValueIt inFirstValue_Y, InputValueIt inLastValue_Y, JKQTPStatGroupDefinitionFunctor1D groupDefFunc=&jkqtpstatGroupingIdentity1D, const QString &columnBaseName=QString("grouped data"))
create a JKQTPFilledCurveXErrorGraph with x-direction error bars, calculated from average +/- stddev ...
Definition jkqtpstatisticsadaptors.h:2677
JKQTPXFunctionLineGraph * jkqtpstatAddRegression(JKQTBasePlotter *plotter, JKQTPStatRegressionModelType type, InputItX firstX, InputItX lastX, InputItY firstY, InputItY lastY, double *coeffA=nullptr, double *coeffB=nullptr, bool fixA=false, bool fixB=false)
calculate the linear regression coefficients for a given data range firstX / firstY ....
Definition jkqtpstatisticsadaptors.h:2004
JKQTPImpulsesVerticalErrorGraph * jkqtpstatAddYErrorImpulsesGraph(JKQTBasePlotter *plotter, InputCatIt inFirstCat_X, InputCatIt inLastCat_X, InputValueIt inFirstValue_Y, InputValueIt inLastValue_Y, JKQTPStatGroupDefinitionFunctor1D groupDefFunc=&jkqtpstatGroupingIdentity1D, const QString &columnBaseName=QString("grouped data"))
create a JKQTPImpulsesVerticalErrorGraph with y-direction error bars, calculated from average +/- std...
Definition jkqtpstatisticsadaptors.h:2459
JKQTPBoxplotVerticalGraph * jkqtpstatVAddBoxplots(JKQTBasePlotter *plotter, InputCatIt inFirstCat_Y, InputCatIt inLastCat_Y, InputValueIt inFirstValue_X, InputValueIt inLastValue_X, double quantile1Spec=0.25, double quantile2Spec=0.75, double minimumQuantile=0, double maximumQuantile=1.0, JKQTPStatGroupDefinitionFunctor1D groupDefFunc=&jkqtpstatGroupingIdentity1D, const QString &columnBaseName=QString("grouped boxplot data"))
create vertical boxplots of type JKQTPBoxplotVerticalGraph, from the 5-value-summary of groups in the...
Definition jkqtpstatisticsadaptors.h:2881
JKQTPColumnContourPlot * jkqtpstatAddHistogram2DContour(JKQTBasePlotter *plotter, InputItX firstX, InputItX lastX, InputItY firstY, InputItY lastY, size_t xbins=10, size_t ybins=10, bool normalized=true, const QString &histogramcolumnBaseName=QString("histogram"), double *oxmin=nullptr, double *oxmax=nullptr, double *oymin=nullptr, double *oymax=nullptr)
calculate calculate a 2-dimensional histogram and add a JKQTPColumnContourPlot to the given plotter,...
Definition jkqtpstatisticsadaptors.h:1114
JKQTPXFunctionLineGraph * jkqtpstatAddWeightedRegression(JKQTBasePlotter *plotter, JKQTPStatRegressionModelType type, InputItX firstX, InputItX lastX, InputItY firstY, InputItY lastY, InputItW firstW, InputItW lastW, double *coeffA=nullptr, double *coeffB=nullptr, bool fixA=false, bool fixB=false, std::function< double(double)> fWeightDataToWi=&jkqtp_identity< double >)
calculate the weighted linear regression coefficients for a given for a given data range firstX / fir...
Definition jkqtpstatisticsadaptors.h:2170
JKQTPXFunctionLineGraph * jkqtpstatAddLinearWeightedRegression(JKQTBasePlotter *plotter, InputItX firstX, InputItX lastX, InputItY firstY, InputItY lastY, InputItW firstW, InputItW lastW, double *coeffA=nullptr, double *coeffB=nullptr, bool fixA=false, bool fixB=false, std::function< double(double)> fWeightDataToWi=&jkqtp_identity< double >)
calculate the weighted linear regression coefficients for a given for a given data range firstX / fir...
Definition jkqtpstatisticsadaptors.h:1918
JKQTPBoxplotHorizontalElement * jkqtpstatAddHBoxplot(JKQTBasePlotter *plotter, InputIt first, InputIt last, double boxposY, double quantile1Spec=0.25, double quantile2Spec=0.75, double minimumQuantile=0, double maximumQuantile=1.0, JKQTPStat5NumberStatistics *statOutput=nullptr)
add a JKQTPBoxplotHorizontalElement to the given plotter, where the boxplot values are calculated fro...
Definition jkqtpstatisticsadaptors.h:67
JKQTPBarHorizontalErrorGraph * jkqtpstatAddXErrorBarGraph(JKQTBasePlotter *plotter, InputCatIt inFirstCat_Y, InputCatIt inLastCat_Y, InputValueIt inFirstValue_Y, InputValueIt inLastValue_Y, JKQTPStatGroupDefinitionFunctor1D groupDefFunc=&jkqtpstatGroupingIdentity1D, const QString &columnBaseName=QString("grouped data"))
create a JKQTPBarHorizontalErrorGraph with x-direction error bars, calculated from average +/- stddev...
Definition jkqtpstatisticsadaptors.h:2605
JKQTPXYLineErrorGraph * jkqtpstatAddXErrorLineGraph(JKQTBasePlotter *plotter, InputCatIt inFirstCat_Y, InputCatIt inLastCat_Y, InputValueIt inFirstValue_Y, InputValueIt inLastValue_Y, JKQTPStatGroupDefinitionFunctor1D groupDefFunc=&jkqtpstatGroupingIdentity1D, const QString &columnBaseName=QString("grouped data"))
create a JKQTPXYLineErrorGraph with x-direction error bars, calculated from average +/- stddev of gro...
Definition jkqtpstatisticsadaptors.h:2581
TGraph * jkqtpstatAddYErrorGraph(JKQTBasePlotter *plotter, InputCatIt inFirstCat_X, InputCatIt inLastCat_X, InputValueIt inFirstValue_Y, InputValueIt inLastValue_Y, JKQTPStatGroupDefinitionFunctor1D groupDefFunc=&jkqtpstatGroupingIdentity1D, const QString &columnBaseName=QString("grouped data"))
create a plot with y-direction error bars, calculated from average +/- stddev of groups in the input ...
Definition jkqtpstatisticsadaptors.h:2367
TGraph * jkqtpstatAddBoxplots(JKQTBasePlotter *plotter, InputCatIt inFirstCat_Y, InputCatIt inLastCat_Y, InputValueIt inFirstValue_Y, InputValueIt inLastValue_Y, double quantile1Spec=0.25, double quantile2Spec=0.75, double minimumQuantile=0, double maximumQuantile=1.0, JKQTPStatGroupDefinitionFunctor1D groupDefFunc=&jkqtpstatGroupingIdentity1D, const QString &columnBaseName=QString("grouped boxplot data"))
create horizontal boxplots of type TGraph, from the 5-value-summary of groups in the input data
Definition jkqtpstatisticsadaptors.h:2815
double jkqtpstatStdDev(InputIt first, InputIt last, double *averageOut=nullptr, size_t *Noutput=nullptr)
calculates the standard deviation of a given data range first ... last
Definition jkqtpstatbasics.h:515
void jkqtpstat5NumberStatistics(InputIt first, InputIt last, double *minimum, double minimumQuantile=0, double *median=nullptr, double *maximum=nullptr, double maximumQuantile=1, double quantile1Spec=0.25, double *quantile1=nullptr, double quantile2Spec=0.75, double *quantile2=nullptr, double *IQR=nullptr, double *IQRSignificance=nullptr, size_t *Noutput=nullptr)
calculates the Five-Number Statistical Summary (minimum, median, maximum and two user-defined quantil...
Definition jkqtpstatbasics.h:1043
double jkqtpstatMedianOfSortedVector(const TVector &data, size_t *Noutput=nullptr)
calculates the median of a given sorted (!) data vector
Definition jkqtpstatbasics.h:800
double jkqtpstatAverage(InputIt first, InputIt last, size_t *Noutput=nullptr)
calculates the average of a given data range first ... last
Definition jkqtpstatbasics.h:62
void jkqtpstatMinMax(InputIt first, InputIt last, double &min, double &max, InputIt *minPos=nullptr, InputIt *maxPos=nullptr, size_t *Noutput=nullptr)
calculates the minimum and maximum values in the given data range first ... last
Definition jkqtpstatbasics.h:168
jkqtmath_LIB_EXPORT double jkqtpstatGroupingIdentity1D(double v)
use a column value as group ID directly
std::function< double(double)> JKQTPStatGroupDefinitionFunctor1D
a functor which assignes a value to a group center
Definition jkqtpstatgrouped.h:54
void jkqtpstatGroupData(InputCatIt inFirstCat, InputCatIt inLastCat, InputValueIt inFirstValue, InputValueIt inLastValue, std::map< double, std::vector< double > > &groupeddata, JKQTPStatGroupDefinitionFunctor1D groupDefFunc=&jkqtpstatGroupingIdentity1D)
groups data from an input range inFirstCat / inFirstValue ... inLastCat / outFirstCat representing pa...
Definition jkqtpstatgrouped.h:108
void jkqtpstatPolyFit(InputItX firstX, InputItX lastX, InputItY firstY, InputItY lastY, size_t P, OutputItP firstRes)
fits (in a least-squares sense) a polynomial of order P to a set of N data pairs
Definition jkqtpstatpoly.h:69
double jkqtpstatWeightedCoefficientOfDetermination(InputItX firstX, InputItX lastX, InputItY firstY, InputItY lastY, InputItW firstW, InputItW lastW, std::function< double(double)> f, std::function< double(double)> fWeightDataToWi=&jkqtp_identity< double >)
calculates the weightedcoefficient of determination for a set of measurements with a fit function
Definition jkqtpstatregression.h:520
jkqtmath_LIB_EXPORT QString jkqtpstatRegressionModel2Latex(JKQTPStatRegressionModelType type, double a, double b)
Generates a LaTeX string for the models from JKQTPStatRegressionModelType in type.
void jkqtpstatRobustIRLSRegression(JKQTPStatRegressionModelType type, InputItX firstX, InputItX lastX, InputItY firstY, InputItY lastY, double &coeffA, double &coeffB, bool fixA=false, bool fixB=false, double p=1.1, int iterations=100)
calculate the robust linear regression coefficients for a given data range firstX / firstY ....
Definition jkqtpstatregression.h:384
void jkqtpstatRegression(JKQTPStatRegressionModelType type, InputItX firstX, InputItX lastX, InputItY firstY, InputItY lastY, double &coeffA, double &coeffB, bool fixA=false, bool fixB=false)
calculate the linear regression coefficients for a given data range firstX / firstY ....
Definition jkqtpstatregression.h:338
double jkqtpstatWeightedSumOfDeviations(InputItX firstX, InputItX lastX, InputItY firstY, InputItY lastY, InputItW firstW, InputItW lastW, std::function< double(double)> f, std::function< double(double)> fWeightDataToWi=&jkqtp_identity< double >)
calculates the weighted sum of deviations for a set of measurements with a fit function
Definition jkqtpstatregression.h:605
void jkqtpstatRobustIRLSLinearRegression(InputItX firstX, InputItX lastX, InputItY firstY, InputItY lastY, double &coeffA, double &coeffB, bool fixA=false, bool fixB=false, double p=1.1, int iterations=100)
calculate the (robust) iteratively reweighted least-squares (IRLS) estimate for the parameters of the...
Definition jkqtpstatregression.h:229
double jkqtpstatCoefficientOfDetermination(InputItX firstX, InputItX lastX, InputItY firstY, InputItY lastY, std::function< double(double)> f)
calculates the coefficient of determination for a set of measurements with a fit function
Definition jkqtpstatregression.h:474
void jkqtpstatWeightedRegression(JKQTPStatRegressionModelType type, InputItX firstX, InputItX lastX, InputItY firstY, InputItY lastY, InputItW firstW, InputItW lastW, double &coeffA, double &coeffB, bool fixA=false, bool fixB=false, std::function< double(double)> fWeightDataToWi=&jkqtp_identity< double >)
calculate the robust linear regression coefficients for a given data range firstX / firstY ....
Definition jkqtpstatregression.h:436
JKQTPStatRegressionModelType
when performing linear regression, different target functions can be fitted, if the input data is tra...
Definition jkqtpstatregression.h:270
void jkqtpstatLinearWeightedRegression(InputItX firstX, InputItX lastX, InputItY firstY, InputItY lastY, InputItW firstW, InputItW lastW, double &coeffA, double &coeffB, bool fixA=false, bool fixB=false, std::function< double(double)> fWeightDataToWi=&jkqtp_identity< double >)
calculate the weighted linear regression coefficients for a given for a given data range firstX / fir...
Definition jkqtpstatregression.h:144
jkqtmath_LIB_EXPORT std::function< double(double, double, double)> jkqtpStatGenerateRegressionModel(JKQTPStatRegressionModelType type)
Generates functors f(x,a,b) for the models from JKQTPStatRegressionModelType in type.
double jkqtpstatSumOfDeviations(InputItX firstX, InputItX lastX, InputItY firstY, InputItY lastY, std::function< double(double)> f)
calculates the sum of deviations for a set of measurements with a fit function
Definition jkqtpstatregression.h:562
void jkqtpstatLinearRegression(InputItX firstX, InputItX lastX, InputItY firstY, InputItY lastY, double &coeffA, double &coeffB, bool fixA=false, bool fixB=false)
calculate the linear regression coefficients for a given data range firstX / firstY ....
Definition jkqtpstatregression.h:71
JKQTCOMMON_LIB_EXPORT QString jkqtp_floattolatexqstr(double data, int past_comma=5, bool remove_trail0=false, double belowIsZero=1e-16, double minNoExponent=1e-3, double maxNoExponent=1e4, bool ensurePlusMinus=false)
convert a double to a string, encoding powers of ten as exponent in LaTeX notation (e....
represents the Five-Number Statistical Summary (minimum, median, maximum and two user-defined quantil...
Definition jkqtpstatbasics.h:1091
double quantile1
first quantile value (specified by quantile1Spec)
Definition jkqtpstatbasics.h:1099
double quantile2
second quantile value (specified by quantile1Spec)
Definition jkqtpstatbasics.h:1105
std::vector< double > outliers
list with the outlier values < minimum and > maximum
Definition jkqtpstatbasics.h:1119
double minimum
minimum value
Definition jkqtpstatbasics.h:1095
double IQRSignificanceEstimate() const
interquartile range, calculated as
double median
median value
Definition jkqtpstatbasics.h:1103
double maximum
maximum value
Definition jkqtpstatbasics.h:1109