X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=src%2Fmath%2Forder-stats.h;h=581bb11455eb9ba5291f87c549e6057ef96ae3db;hb=71f9b6d6c14525cd41ba77c9fd50aa13d0da830c;hp=07da284aa26af9faa95df9872d00163092471686;hpb=9e0e4996fad6563f0a1ce628b80db5c23ef8279e;p=pspp diff --git a/src/math/order-stats.h b/src/math/order-stats.h index 07da284aa2..581bb11455 100644 --- a/src/math/order-stats.h +++ b/src/math/order-stats.h @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 2004, 2008 Free Software Foundation, Inc. + Copyright (C) 2004, 2008, 2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,9 +17,28 @@ #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 -#include +#include "data/missing-values.h" +#include "math/statistic.h" struct casereader; struct variable; @@ -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,14 +68,17 @@ struct order_stats double cc; }; -enum mv_class; - -void order_stats_dump (const struct order_stats *os); - -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