1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 2004, 2008, 2011 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17 #ifndef __ORDER_STATS_H__
18 #define __ORDER_STATS_H__
20 /* Support for order statistics.
22 This data structure supplies infrastructure for higher-level statistics that
23 rely on order statistics. It is a kind of "abstract base class" that is not
24 useful on its own. The common pattern for using the statistics based on it
27 - Create the higher-level statistic with, for example, percentile_create().
29 - Feed in all the data with order_stats_accumulate() or
30 order_stats_accumulate_idx(). The data must be in sorted order: if
31 necessary, use one of the sorting functions from sort.h to sort them.
33 - Obtain the desired results by examining the higher-level data structure or
34 by calling an appropriate function, e.g. percentile_calculate().
36 - Destroy the data structure with statistic_destroy().
40 #include "data/missing-values.h"
41 #include "math/statistic.h"
60 /* Order statistics calculation data structure. See the comment at the top of
61 this file for usage details. */
64 struct statistic parent;
71 void order_stats_accumulate_idx (struct order_stats **os, size_t n_os,
72 struct casereader *reader,
75 void order_stats_accumulate (struct order_stats **os, size_t n_os,
77 const struct variable *weight_var,
78 const struct variable *data_var,
79 enum mv_class exclude);
81 /* Debugging support. */
82 void order_stats_dump (const struct order_stats *);