math: Improve comments.
[pspp] / src / math / order-stats.h
index 03011ea32c4116a3045e45a61e532c7dfa57bd87..581bb11455eb9ba5291f87c549e6057ef96ae3db 100644 (file)
 #ifndef __ORDER_STATS_H__
 #define __ORDER_STATS_H__
 
+/* Support for order statistics.
+
+   This data structure supplies infrastructure for higher-level statistics that
+   rely on order statistics.  It is a kind of "abstract base class" that is not
+   useful on its own.  The common pattern for using the statistics based on it
+   is this:
+
+   - Create the higher-level statistic with, for example, percentile_create().
+
+   - Feed in all the data with order_stats_accumulate() or
+     order_stats_accumulate_idx(). The data must be in sorted order: if
+     necessary, use one of the sorting functions from sort.h to sort them.
+
+   - Obtain the desired results by examining the higher-level data structure or
+     by calling an appropriate function, e.g. percentile_calculate().
+
+   - Destroy the data structure with statistic_destroy().
+*/
+
 #include <stddef.h>
 #include "data/missing-values.h"
 #include "math/statistic.h"
@@ -38,7 +57,8 @@ struct k
   double y_p1;
 };
 
-
+/* Order statistics calculation data structure.  See the comment at the top of
+   this file for usage details. */
 struct order_stats
 {
   struct statistic parent;
@@ -48,21 +68,17 @@ struct order_stats
   double cc;
 };
 
-enum mv_class;
-
-void order_stats_dump (const struct order_stats *os);
-
-void
-order_stats_accumulate_idx (struct order_stats **os, size_t nos,
-                            struct casereader *reader,
-                            int wt_idx,
-                            int val_idx);
-
-
-void order_stats_accumulate (struct order_stats **ptl, size_t nos,
-                            struct casereader *reader,
-                            const struct variable *wv,
-                            const struct variable *var,
+void order_stats_accumulate_idx (struct order_stats **os, size_t n_os,
+                                 struct casereader *reader,
+                                 int weight_idx,
+                                 int data_idx);
+void order_stats_accumulate (struct order_stats **os, size_t n_os,
+                            struct casereader *,
+                            const struct variable *weight_var,
+                            const struct variable *data_var,
                             enum mv_class exclude);
 
+/* Debugging support. */
+void order_stats_dump (const struct order_stats *);
+
 #endif