X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fstats%2Froc.c;h=1d61a55c57a3cad25c834c204c3571632d9df778;hb=91a5888ad22ff93d212c9534d720d8f8bf52e56b;hp=024c9f85297c5bf3fc15fae0f7af95fac121b09e;hpb=3d8d78ad9ca206b6489cc3944c985c8ba89e4b1e;p=pspp-builds.git diff --git a/src/language/stats/roc.c b/src/language/stats/roc.c index 024c9f85..1d61a55c 100644 --- a/src/language/stats/roc.c +++ b/src/language/stats/roc.c @@ -98,18 +98,18 @@ cmd_roc (struct lexer *lexer, struct dataset *ds) if (!parse_variables_const (lexer, dict, &roc.vars, &roc.n_vars, PV_APPEND | PV_NO_DUPLICATE | PV_NUMERIC)) - goto error;; + goto error; if ( ! lex_force_match (lexer, T_BY)) { - goto error;; + goto error; } roc.state_var = parse_variable (lexer, dict); if ( !lex_force_match (lexer, '(')) { - goto error;; + goto error; } parse_value (lexer, &roc.state_value, var_get_width (roc.state_var)); @@ -117,7 +117,7 @@ cmd_roc (struct lexer *lexer, struct dataset *ds) if ( !lex_force_match (lexer, ')')) { - goto error;; + goto error; } @@ -140,7 +140,7 @@ cmd_roc (struct lexer *lexer, struct dataset *ds) else { lex_error (lexer, NULL); - goto error;; + goto error; } } } @@ -164,7 +164,7 @@ cmd_roc (struct lexer *lexer, struct dataset *ds) else { lex_error (lexer, NULL); - goto error;; + goto error; } } else if (lex_match_id (lexer, "PRINT")) @@ -183,7 +183,7 @@ cmd_roc (struct lexer *lexer, struct dataset *ds) else { lex_error (lexer, NULL); - goto error;; + goto error; } } } @@ -206,7 +206,7 @@ cmd_roc (struct lexer *lexer, struct dataset *ds) else { lex_error (lexer, NULL); - goto error;; + goto error; } lex_force_match (lexer, ')'); } @@ -224,7 +224,7 @@ cmd_roc (struct lexer *lexer, struct dataset *ds) else { lex_error (lexer, NULL); - goto error;; + goto error; } lex_force_match (lexer, ')'); } @@ -250,14 +250,14 @@ cmd_roc (struct lexer *lexer, struct dataset *ds) else { lex_error (lexer, NULL); - goto error;; + goto error; } lex_force_match (lexer, ')'); } else { lex_error (lexer, NULL); - goto error;; + goto error; } } } @@ -269,8 +269,9 @@ cmd_roc (struct lexer *lexer, struct dataset *ds) } if ( ! run_roc (ds, &roc)) - goto error;; + goto error; + free (roc.vars); return CMD_SUCCESS; error: @@ -365,14 +366,16 @@ match_positives (const struct ccase *c, void *aux) standard error values */ struct roc_state { - double auc; + double auc; /* Area under the curve */ - double n1; - double n2; + double n1; /* total weight of positives */ + double n2; /* total weight of negatives */ - double q1hat; + /* intermediates for standard error */ + double q1hat; double q2hat; + /* intermediates for cutpoints */ struct casewriter *cutpoint_wtr; struct casereader *cutpoint_rdr; double prev_result; @@ -440,7 +443,21 @@ accumulate_counts (struct casereader *cutpoint_rdr, static void output_roc (struct roc_state *rs, const struct cmd_roc *roc); +/* + This function does 3 things: + + 1. Counts the number of cases which are equal to every other case in READER, + and those cases for which the relationship between it and every other case + satifies PRED (normally either > or <). VAR is variable defining a case's value + for this purpose. + 2. Counts the number of true and false cases in reader, and populates + CUTPOINT_RDR accordingly. TRUE_INDEX and FALSE_INDEX are the indices + which receive these values. POS_COND is the condition defining true + and false. + + 3. CC is filled with the cumulative weight of all cases of READER. +*/ static struct casereader * process_group (const struct variable *var, struct casereader *reader, bool (*pred) (double, double), @@ -945,9 +962,9 @@ show_auc (struct roc_state *rs, const struct cmd_roc *roc) tab_text (tbl, n_cols - 2, 1, TAT_TITLE, _("Lower Bound")); tab_text (tbl, n_cols - 1, 1, TAT_TITLE, _("Upper Bound")); - tab_joint_text (tbl, n_cols - 2, 0, 4, 0, - TAT_TITLE | TAB_CENTER | TAT_PRINTF, - _("Asymp. %g%% Confidence Interval"), roc->ci); + tab_joint_text_format (tbl, n_cols - 2, 0, 4, 0, + TAT_TITLE | TAB_CENTER, + _("Asymp. %g%% Confidence Interval"), roc->ci); tab_vline (tbl, 0, n_cols - 1, 0, 0); tab_hline (tbl, TAL_1, n_cols - 2, n_cols - 1, 1); }