- np->y_min = np->ns_min = np->dns_min = DBL_MAX;
- np->y_max = np->ns_max = np->dns_max = -DBL_MAX;
-
- np->writer = autopaging_writer_create (n_NP_IDX);
-
- os->k = 0;
- stat->destroy = destroy;
- stat->accumulate = acc;
-
- return os;
+ The caller must eventually destroy the returned structure, with
+ statistic_destroy(). */
+struct np *
+np_create (double n, double mean, double var)
+{
+ struct caseproto *proto = caseproto_create ();
+ for (size_t i = 0; i < n_NP_IDX; i++)
+ proto = caseproto_add_width (proto, 0);
+ struct casewriter *writer = autopaging_writer_create (proto);
+ caseproto_unref (proto);
+
+ struct np *np = xmalloc (sizeof *np);
+ *np = (struct np) {
+ .parent = {
+ .parent = {
+ .destroy = destroy,
+ },
+ .accumulate = acc,
+ },
+ .n = n,
+ .mean = mean,
+ .stddev = sqrt (var),
+ .ns_min = DBL_MAX,
+ .ns_max = -DBL_MAX,
+ .dns_min = DBL_MAX,
+ .dns_max = -DBL_MAX,
+ .y_min = DBL_MAX,
+ .y_max = -DBL_MAX,
+ .writer = writer,
+ };
+ return np;