]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
quantiles: add functions to get max k and min step
authorMiroslav Lichvar <mlichvar@redhat.com>
Mon, 18 Nov 2024 14:54:17 +0000 (15:54 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 21 Nov 2024 08:05:58 +0000 (09:05 +0100)
hwclock.c
quantiles.c
quantiles.h
test/unit/quantiles.c

index 86c7e51de49a162c4393f6c8500646916a500242..c662dae3d0f6de67bd9b91af92d5f20ba1c868a4 100644 (file)
--- a/hwclock.c
+++ b/hwclock.c
@@ -199,8 +199,8 @@ HCL_ProcessReadings(HCL_Instance clock, int n_readings, struct timespec tss[][3]
 
   local_prec = LCL_GetSysPrecisionAsQuantum();
 
-  low_delay = QNT_GetQuantile(clock->delay_quants, DELAY_QUANT_MIN_K);
-  high_delay = QNT_GetQuantile(clock->delay_quants, DELAY_QUANT_MAX_K);
+  low_delay = QNT_GetQuantile(clock->delay_quants, QNT_GetMinK(clock->delay_quants));
+  high_delay = QNT_GetQuantile(clock->delay_quants, QNT_GetMaxK(clock->delay_quants));
   low_delay = MIN(low_delay, high_delay);
   high_delay = MAX(high_delay, low_delay + local_prec);
 
index 27283eaac06cf329967dd1110fa1b01b199a98f6..a579b29785e4f3af259bd913fad56c815b34515a 100644 (file)
@@ -193,6 +193,22 @@ QNT_GetMinK(QNT_Instance inst)
 
 /* ================================================== */
 
+int
+QNT_GetMaxK(QNT_Instance inst)
+{
+  return inst->min_k + (inst->n_quants / inst->repeat) - 1;
+}
+
+/* ================================================== */
+
+double
+QNT_GetMinStep(QNT_Instance inst)
+{
+  return inst->min_step;
+}
+
+/* ================================================== */
+
 double
 QNT_GetQuantile(QNT_Instance inst, int k)
 {
index 1788544eb01d01526fda2ebe5856decdbf2ebae1..b9665d508ff74df9e5b00a9e1249f0b96bef5dfa 100644 (file)
@@ -36,6 +36,8 @@ 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 int QNT_GetMaxK(QNT_Instance inst);
+extern double QNT_GetMinStep(QNT_Instance inst);
 extern double QNT_GetQuantile(QNT_Instance inst, int k);
 
 #endif
index 5d97df6e36cc7ece81d43cfae119ce600b013e21..86907808e5a6824389df1f94625afa6eb19ff2ee 100644 (file)
@@ -43,6 +43,8 @@ test_unit(void)
     inst = QNT_CreateInstance(min_k, max_k, q, r, 1e-9);
 
     TEST_CHECK(min_k == QNT_GetMinK(inst));
+    TEST_CHECK(max_k == QNT_GetMaxK(inst));
+    TEST_CHECK(fabs(QNT_GetMinStep(inst) - 1e-9) < 1e-12);
 
     for (j = 0; j < 3000; j++) {
       x = TST_GetRandomDouble(0.0, 2e-6);