X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fstats%2Fks-one-sample.c;h=ea7ac71b7e036aa5d39456f67cae4ffa26f921c4;hb=0e0cabc772b5f3a416e1e4e1dc021e196ac2c443;hp=aaab53fa891a4e09b11b56b2a453a823547ab682;hpb=90a008db8b2f6e5bec903e584eb68e9bb20c061e;p=pspp diff --git a/src/language/stats/ks-one-sample.c b/src/language/stats/ks-one-sample.c index aaab53fa89..ea7ac71b7e 100644 --- a/src/language/stats/ks-one-sample.c +++ b/src/language/stats/ks-one-sample.c @@ -93,7 +93,7 @@ theoretical_exponential (const struct ks *ks, double x) } -static const theoreticalfp theoreticalf[4] = +static const theoreticalfp theoreticalf[4] = { theoretical_normal, theoretical_uniform, @@ -101,7 +101,7 @@ static const theoreticalfp theoreticalf[4] = theoretical_exponential }; -/* +/* Return the assymptotic approximation to the significance of Z */ static double @@ -109,7 +109,7 @@ ks_asymp_sig (double z) { if (z < 0.27) return 1; - + if (z >= 3.1) return 0; @@ -166,7 +166,7 @@ ks_one_sample_execute (const struct dataset *ds, { const struct variable *var = ost->vars[v]; const union value *val = case_data (c, var); - + if (var_is_value_missing (var, val, exclude)) continue; @@ -215,7 +215,7 @@ ks_one_sample_execute (const struct dataset *ds, case KS_EXPONENTIAL: if (kst->p[0] != SYSMIS) ks[v].mu = ks[v].sigma = kst->p[0]; - else + else ks[v].mu = ks[v].sigma = ks[v].sum / ks[v].obs_cc; break; default: @@ -236,19 +236,19 @@ ks_one_sample_execute (const struct dataset *ds, cc += weight; empirical = cc / ks[v].obs_cc; - + theoretical = theoreticalf[kst->dist] (&ks[v], val->f); - + d = empirical - theoretical; dp = prev_empirical - theoretical; if (d > 0) - maximize (&ks[v].diff_pos, d); + maximize (&ks[v].diff_pos, d); else minimize (&ks[v].diff_neg, d); if (dp > 0) - maximize (&ks[v].diff_pos, dp); + maximize (&ks[v].diff_pos, dp); else minimize (&ks[v].diff_neg, dp); @@ -276,7 +276,7 @@ show_results (const struct ks *ks, const int nc = kst->parent.n_vars + column_headers; const int nr = 8 + row_headers; struct tab_table *table = tab_create (nc, nr); - + tab_set_format (table, RC_WEIGHT, wfmt); tab_headers (table, row_headers, 0, column_headers, 0); tab_title (table, _("One-Sample Kolmogorov-Smirnov Test")); @@ -297,7 +297,7 @@ show_results (const struct ks *ks, case KS_NORMAL: tab_text (table, 0, 2, TAT_TITLE | TAB_LEFT , _("Normal Parameters")); - + tab_text (table, 1, 2, TAT_TITLE | TAB_LEFT , _("Mean")); tab_text (table, 1, 3, @@ -306,7 +306,7 @@ show_results (const struct ks *ks, case KS_UNIFORM: tab_text (table, 0, 2, TAT_TITLE | TAB_LEFT , _("Uniform Parameters")); - + tab_text (table, 1, 2, TAT_TITLE | TAB_LEFT , _("Minimum")); tab_text (table, 1, 3, @@ -315,14 +315,14 @@ show_results (const struct ks *ks, case KS_POISSON: tab_text (table, 0, 2, TAT_TITLE | TAB_LEFT , _("Poisson Parameters")); - + tab_text (table, 1, 2, TAT_TITLE | TAB_LEFT , _("Lambda")); break; case KS_EXPONENTIAL: tab_text (table, 0, 2, TAT_TITLE | TAB_LEFT , _("Exponential Parameters")); - + tab_text (table, 1, 2, TAT_TITLE | TAB_LEFT , _("Scale")); break; @@ -338,27 +338,27 @@ show_results (const struct ks *ks, double z = 0; const int col = 2 + i; tab_text (table, col, 0, - TAT_TITLE | TAB_CENTER , + TAT_TITLE | TAB_CENTER , var_to_string (kst->parent.vars[i])); switch (kst->dist) { case KS_UNIFORM: - tab_double (table, col, 1, 0, ks[i].obs_cc, wfmt); - tab_double (table, col, 2, 0, ks[i].test_min, NULL); - tab_double (table, col, 3, 0, ks[i].test_max, NULL); + tab_double (table, col, 1, 0, ks[i].obs_cc, NULL, RC_WEIGHT); + tab_double (table, col, 2, 0, ks[i].test_min, NULL, RC_OTHER); + tab_double (table, col, 3, 0, ks[i].test_max, NULL, RC_OTHER); break; case KS_NORMAL: - tab_double (table, col, 1, 0, ks[i].obs_cc, wfmt); - tab_double (table, col, 2, 0, ks[i].mu, NULL); - tab_double (table, col, 3, 0, ks[i].sigma, NULL); + tab_double (table, col, 1, 0, ks[i].obs_cc, NULL, RC_WEIGHT); + tab_double (table, col, 2, 0, ks[i].mu, NULL, RC_OTHER); + tab_double (table, col, 3, 0, ks[i].sigma, NULL, RC_OTHER); break; case KS_POISSON: case KS_EXPONENTIAL: - tab_double (table, col, 1, 0, ks[i].obs_cc, wfmt); - tab_double (table, col, 2, 0, ks[i].mu, NULL); + tab_double (table, col, 1, 0, ks[i].obs_cc, NULL, RC_WEIGHT); + tab_double (table, col, 2, 0, ks[i].mu, NULL, RC_OTHER); break; default: @@ -370,13 +370,13 @@ show_results (const struct ks *ks, z = sqrt (ks[i].obs_cc) * abs; - tab_double (table, col, 5, 0, ks[i].diff_pos, NULL); - tab_double (table, col, 6, 0, ks[i].diff_neg, NULL); + tab_double (table, col, 5, 0, ks[i].diff_pos, NULL, RC_OTHER); + tab_double (table, col, 6, 0, ks[i].diff_neg, NULL, RC_OTHER); - tab_double (table, col, 4, 0, abs, NULL); + tab_double (table, col, 4, 0, abs, NULL, RC_OTHER); - tab_double (table, col, 7, 0, z, NULL); - tab_double (table, col, 8, 0, ks_asymp_sig (z), NULL); + tab_double (table, col, 7, 0, z, NULL, RC_OTHER); + tab_double (table, col, 8, 0, ks_asymp_sig (z), NULL, RC_PVALUE); }