math: Improve comments.
[pspp] / src / math / percentiles.c
index b43fed461612d7a6f0e63ab8ddbc0fad7f549422..79514eb2504f95d9fd3bfad37c3854aa8fe8c510 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "gl/xalloc.h"
 
+/* Return the value of the percentile. */
 double
 percentile_calculate (const struct percentile *ptl, enum pc_alg alg)
 {
@@ -139,12 +140,13 @@ static void
 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);
 }
 
 
+/* Create the Pth percentile.
+   W is the total sum of weights in the data set.
+*/
 struct percentile *
 percentile_create (double p, double W)
 {
@@ -159,7 +161,7 @@ percentile_create (double p, double W)
   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;