1 /* PSPP - a program for statistical analysis. 2 Copyright (C) 2004, 2008, 2009 Free Software Foundation, Inc. 3 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. 8 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. 13 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/>. */ 16 17 #ifndef __PERCENTILES_H__ 18 #define __PERCENTILES_H__ 19 20 #include <stddef.h> 21 22 #include "order-stats.h" 23 24 /* The algorithm used to calculate percentiles */ 25 enum pc_alg { 26 PC_NONE=0, 27 PC_HAVERAGE, 28 PC_WAVERAGE, 29 PC_ROUND, 30 PC_EMPIRICAL, 31 PC_AEMPIRICAL 32 } ; 33 34 extern const char *const ptile_alg_desc[]; 35 36 37 struct percentile 38 { 39 struct order_stats parent; 40 41 double ptile; 42 double w; 43 44 /* Mutable */ 45 double g1; 46 double g1_star; 47 48 double g2; 49 double g2_star; 50 }; 51 52 /* Create the Pth percentile. 53 W is the total sum of weights in the data set 54 */ 55 struct percentile *percentile_create (double p, double W); 56 57 /* Return the value of the percentile */ 58 double percentile_calculate (const struct percentile *ptl, enum pc_alg alg); 59 60 void percentile_dump (const struct percentile *ptl); 61 62 63 #endif 64