]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
quantiles: add function to get minimum k
authorMiroslav Lichvar <mlichvar@redhat.com>
Tue, 19 Jul 2022 12:33:40 +0000 (14:33 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 21 Jul 2022 13:33:35 +0000 (15:33 +0200)
quantiles.c
quantiles.h
test/unit/quantiles.c

index 8b72a6153c95b5e54e61ae16f83cdeca2e15c80f..52953db46cf534103261fb7645ae1db82f968b1a 100644 (file)
@@ -185,6 +185,14 @@ QNT_Accumulate(QNT_Instance inst, double value)
 
 /* ================================================== */
 
+int
+QNT_GetMinK(QNT_Instance inst)
+{
+  return inst->min_k;
+}
+
+/* ================================================== */
+
 double
 QNT_GetQuantile(QNT_Instance inst, int k)
 {
index 590105ed0682e01913ee89683751f7a3cd371676..1788544eb01d01526fda2ebe5856decdbf2ebae1 100644 (file)
@@ -35,6 +35,7 @@ extern void QNT_DestroyInstance(QNT_Instance inst);
 
 extern void QNT_Reset(QNT_Instance inst);
 extern void QNT_Accumulate(QNT_Instance inst, double value);
+extern int QNT_GetMinK(QNT_Instance inst);
 extern double QNT_GetQuantile(QNT_Instance inst, int k);
 
 #endif
index fc6364bc5f263161b181a7b66d018a3c073fb04c..5d97df6e36cc7ece81d43cfae119ce600b013e21 100644 (file)
@@ -42,6 +42,8 @@ test_unit(void)
 
     inst = QNT_CreateInstance(min_k, max_k, q, r, 1e-9);
 
+    TEST_CHECK(min_k == QNT_GetMinK(inst));
+
     for (j = 0; j < 3000; j++) {
       x = TST_GetRandomDouble(0.0, 2e-6);
       QNT_Accumulate(inst, x);