From: Ben Pfaff Date: Sun, 30 Jan 2022 00:59:31 +0000 (-0800) Subject: Add ptile support (untested). X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?p=pspp;a=commitdiff_plain;h=e84a26c32c9acf582772d1b4fd5e237fc0865dc3 Add ptile support (untested). --- diff --git a/src/language/stats/ctables.c b/src/language/stats/ctables.c index 17032c8c8e..2edd40d5d3 100644 --- a/src/language/stats/ctables.c +++ b/src/language/stats/ctables.c @@ -1686,7 +1686,7 @@ union ctables_summary /* MEAN, SEMEAN, STDDEV, SUM, VARIANCE, *.SUM. */ struct moments1 *moments; - /* MEDIAN, MODE. */ + /* MEDIAN, MODE, PTILE. */ struct { struct casewriter *writer; @@ -1694,7 +1694,7 @@ union ctables_summary double ovalue; }; - /* XXX percentiles, mode, multiple response */ + /* XXX multiple response */ }; static void @@ -1757,6 +1757,7 @@ ctables_summary_init (union ctables_summary *s, case CTSF_MEDIAN: case CTSF_MODE: + case CTSF_PTILE: { struct caseproto *proto = caseproto_create (); proto = caseproto_add_width (proto, 0); @@ -1773,9 +1774,6 @@ ctables_summary_init (union ctables_summary *s, } break; - case CTSF_PTILE: - NOT_REACHED (); - case CTSF_RESPONSES: case CTSF_ROWPCT_RESPONSES: case CTSF_COLPCT_RESPONSES: @@ -1860,12 +1858,10 @@ ctables_summary_uninit (union ctables_summary *s, case CTSF_MEDIAN: case CTSF_MODE: + case CTSF_PTILE: casewriter_destroy (s->writer); break; - case CTSF_PTILE: - NOT_REACHED (); - case CTSF_RESPONSES: case CTSF_ROWPCT_RESPONSES: case CTSF_COLPCT_RESPONSES: @@ -1965,6 +1961,7 @@ ctables_summary_add (union ctables_summary *s, case CTSF_MEDIAN: case CTSF_MODE: + case CTSF_PTILE: if (var_is_value_missing (var, value)) { s->ovalid += weight; @@ -1976,9 +1973,6 @@ ctables_summary_add (union ctables_summary *s, } break; - case CTSF_PTILE: - NOT_REACHED (); - case CTSF_RESPONSES: case CTSF_ROWPCT_RESPONSES: case CTSF_COLPCT_RESPONSES: @@ -2118,16 +2112,18 @@ ctables_summary_value (const struct ctables_cell *cell, NOT_REACHED (); case CTSF_MEDIAN: + case CTSF_PTILE: if (s->writer) { struct casereader *reader = casewriter_make_reader (s->writer); s->writer = NULL; - struct percentile *median = percentile_create (0.5, s->ovalid); - struct order_stats *os = &median->parent; + struct percentile *ptile = percentile_create ( + ss->function == CTSF_PTILE ? ss->percentile : 0.5, s->ovalid); + struct order_stats *os = &ptile->parent; order_stats_accumulate_idx (&os, 1, reader, 1, 0); - s->ovalue = percentile_calculate (median, PC_HAVERAGE); - statistic_destroy (&median->parent.parent); + s->ovalue = percentile_calculate (ptile, PC_HAVERAGE); + statistic_destroy (&ptile->parent.parent); } return s->ovalue; @@ -2145,9 +2141,6 @@ ctables_summary_value (const struct ctables_cell *cell, } return s->ovalue; - case CTSF_PTILE: - NOT_REACHED (); - case CTSF_RESPONSES: case CTSF_ROWPCT_RESPONSES: case CTSF_COLPCT_RESPONSES: