/* MEAN, SEMEAN, STDDEV, SUM, VARIANCE, *.SUM. */
struct moments1 *moments;
- /* MEDIAN, MODE. */
+ /* MEDIAN, MODE, PTILE. */
struct
{
struct casewriter *writer;
double ovalue;
};
- /* XXX percentiles, mode, multiple response */
+ /* XXX multiple response */
};
static void
case CTSF_MEDIAN:
case CTSF_MODE:
+ case CTSF_PTILE:
{
struct caseproto *proto = caseproto_create ();
proto = caseproto_add_width (proto, 0);
}
break;
- case CTSF_PTILE:
- NOT_REACHED ();
-
case CTSF_RESPONSES:
case CTSF_ROWPCT_RESPONSES:
case CTSF_COLPCT_RESPONSES:
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:
case CTSF_MEDIAN:
case CTSF_MODE:
+ case CTSF_PTILE:
if (var_is_value_missing (var, value))
{
s->ovalid += weight;
}
break;
- case CTSF_PTILE:
- NOT_REACHED ();
-
case CTSF_RESPONSES:
case CTSF_ROWPCT_RESPONSES:
case CTSF_COLPCT_RESPONSES:
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;
}
return s->ovalue;
- case CTSF_PTILE:
- NOT_REACHED ();
-
case CTSF_RESPONSES:
case CTSF_ROWPCT_RESPONSES:
case CTSF_COLPCT_RESPONSES: