X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fstats%2Fmedian.c;h=49a4bc12e8bd6042efc38794761d1a88d0954386;hb=d4ff0e074d703dbeb8af5aa3ac470ddda5ebe301;hp=a894f017a708d8994f1ddd79feee31f573185c00;hpb=0f630668763ae95b92424012e675ef9e22d1abad;p=pspp
diff --git a/src/language/stats/median.c b/src/language/stats/median.c
index a894f017a7..49a4bc12e8 100644
--- a/src/language/stats/median.c
+++ b/src/language/stats/median.c
@@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see .
+ along with this program. If not, see .
*/
#include
@@ -61,12 +61,12 @@ struct results
struct val_node **sorted_array;
double n;
double median;
- double chisq;
+ double chisq;
};
-static int
+static int
val_node_cmp_3way (const void *a_, const void *b_, const void *aux)
{
const struct variable *indep_var = aux;
@@ -76,15 +76,15 @@ val_node_cmp_3way (const void *a_, const void *b_, const void *aux)
return value_compare_3way (&(*a)->val, &(*b)->val, var_get_width (indep_var));
}
-static void
+static void
show_frequencies (const struct n_sample_test *nst, const struct results *results, int n_vals, const struct dictionary *);
-static void
+static void
show_test_statistics (const struct n_sample_test *nst, const struct results *results, int, const struct dictionary *);
static struct val_node *
-find_value (const struct hmap *map, const union value *val,
+find_value (const struct hmap *map, const union value *val,
const struct variable *var)
{
struct val_node *foo = NULL;
@@ -174,7 +174,7 @@ median_execute (const struct dataset *ds,
ptl = percentile_create (0.5, cc);
os = &ptl->parent;
-
+
order_stats_accumulate (&os, 1,
rr,
wvar,
@@ -186,7 +186,7 @@ median_execute (const struct dataset *ds,
}
results[v].median = median;
-
+
for (; (c = casereader_read (r)) != NULL; case_unref (c))
{
@@ -222,7 +222,7 @@ median_execute (const struct dataset *ds,
int width = var_get_width (nst->indep_var);
vn = xzalloc (sizeof *vn);
value_clone (&vn->val, indep_val, width);
-
+
hmap_insert (&map, &vn->node, value_hash (indep_val, width, 0));
}
else
@@ -269,7 +269,7 @@ median_execute (const struct dataset *ds,
n_vals = x;
hmap_destroy (&map);
- sort (results[v].sorted_array, x, sizeof (*results[v].sorted_array),
+ sort (results[v].sorted_array, x, sizeof (*results[v].sorted_array),
val_node_cmp_3way, nst->indep_var);
}
@@ -298,7 +298,7 @@ median_execute (const struct dataset *ds,
-static void
+static void
show_frequencies (const struct n_sample_test *nst, const struct results *results, int n_vals, const struct dictionary *dict)
{
const struct variable *weight = dict_get_weight (dict);
@@ -311,8 +311,9 @@ show_frequencies (const struct n_sample_test *nst, const struct results *results
const int column_headers = 2;
const int nc = row_headers + n_vals;
const int nr = column_headers + nst->n_vars * 2;
-
+
struct tab_table *table = tab_create (nc, nr);
+ tab_set_format (table, RC_WEIGHT, wfmt);
tab_headers (table, row_headers, 0, column_headers, 0);
@@ -344,7 +345,7 @@ show_frequencies (const struct n_sample_test *nst, const struct results *results
tab_text (table, row_headers + i, 1,
TAT_TITLE | TAB_LEFT, ds_cstr (&label));
-
+
ds_destroy (&label);
}
@@ -373,10 +374,10 @@ show_frequencies (const struct n_sample_test *nst, const struct results *results
{
const struct val_node *vn = rs->sorted_array[i];
tab_double (table, row_headers + i, column_headers + v * 2,
- 0, vn->gt, wfmt);
+ 0, vn->gt, NULL, RC_WEIGHT);
tab_double (table, row_headers + i, column_headers + v * 2 + 1,
- 0, vn->le, wfmt);
+ 0, vn->le, NULL, RC_WEIGHT);
}
}
@@ -384,7 +385,7 @@ show_frequencies (const struct n_sample_test *nst, const struct results *results
}
-static void
+static void
show_test_statistics (const struct n_sample_test *nst,
const struct results *results,
int n_vals,
@@ -399,8 +400,9 @@ show_test_statistics (const struct n_sample_test *nst,
const int column_headers = 1;
const int nc = row_headers + 5;
const int nr = column_headers + nst->n_vars;
-
+
struct tab_table *table = tab_create (nc, nr);
+ tab_set_format (table, RC_WEIGHT, wfmt);
tab_headers (table, row_headers, 0, column_headers, 0);
@@ -438,20 +440,20 @@ show_test_statistics (const struct n_sample_test *nst,
tab_double (table, row_headers + 0, column_headers + v,
- 0, rs->n, wfmt);
+ 0, rs->n, NULL, RC_WEIGHT);
tab_double (table, row_headers + 1, column_headers + v,
- 0, rs->median, NULL);
+ 0, rs->median, NULL, RC_OTHER);
tab_double (table, row_headers + 2, column_headers + v,
- 0, rs->chisq, NULL);
+ 0, rs->chisq, NULL, RC_OTHER);
tab_double (table, row_headers + 3, column_headers + v,
- 0, df, wfmt);
+ 0, df, NULL, RC_WEIGHT);
tab_double (table, row_headers + 4, column_headers + v,
- 0, gsl_cdf_chisq_Q (rs->chisq, df), NULL);
+ 0, gsl_cdf_chisq_Q (rs->chisq, df), NULL, RC_PVALUE);
}
-
+
tab_submit (table);
}