X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fmath%2Forder-stats.h;fp=src%2Fmath%2Forder-stats.h;h=581bb11455eb9ba5291f87c549e6057ef96ae3db;hb=feb269112e14589474c0a75e96cd5a892d9aaeef;hp=03011ea32c4116a3045e45a61e532c7dfa57bd87;hpb=922dfe227e0a157f895c025b8f8590e2bfc59f23;p=pspp diff --git a/src/math/order-stats.h b/src/math/order-stats.h index 03011ea32c..581bb11455 100644 --- a/src/math/order-stats.h +++ b/src/math/order-stats.h @@ -17,6 +17,25 @@ #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 #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