This seems generally a bit cleaner to me.
destroy (struct statistic *stat)
{
struct percentile *ptl = UP_CAST (stat, struct percentile, parent.parent);
- struct order_stats *os = &ptl->parent;
- free (os->k);
free (ptl);
}
ptl->w = W;
os->n_k = 2;
- os->k = xcalloc (2, sizeof (*os->k));
+ os->k = ptl->k;
os->k[0].tc = W * p;
os->k[1].tc = (W + 1.0) * p;
double g2;
double g2_star;
+
+ struct k k[2];
};
/* Create the Pth percentile.
destroy (struct statistic *s)
{
struct trimmed_mean *tm = UP_CAST (s, struct trimmed_mean, parent.parent);
- struct order_stats *os = &tm->parent;
- free (os->k);
free (tm);
}
struct statistic *stat = &os->parent;
os->n_k = 2;
- os->k = xcalloc (2, sizeof (*os->k));
+ os->k = tm->k;
assert (tail >= 0);
assert (tail <= 1);
double w;
double tail;
+
+ struct k k[2];
};
struct trimmed_mean * trimmed_mean_create (double W, double c_min);
destroy (struct statistic *s)
{
struct tukey_hinges *th = UP_CAST (s, struct tukey_hinges, parent.parent);
- struct order_stats *os = &th->parent;
-
- free (os->k);
- free (s);
+ free (th);
};
struct tukey_hinges *
assert (c_min >= 0);
os->n_k = 3;
- os->k = xcalloc (3, sizeof (*os->k));
+ os->k = th->k;
if (c_min >= 1.0)
{
struct tukey_hinges
{
struct order_stats parent;
+ struct k k[3];
};
struct tukey_hinges * tukey_hinges_create (double W, double c_min);