/* PSPP - EXAMINE data for normality . -*-c-*-
Copyright (C) 2004 Free Software Foundation, Inc.
/* PSPP - EXAMINE data for normality . -*-c-*-
Copyright (C) 2004 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
/* Parse the clause specifying the factors */
static int examine_parse_independent_vars (struct lexer *lexer, const struct dictionary *dict, struct cmd_examine *cmd);
/* Parse the clause specifying the factors */
static int examine_parse_independent_vars (struct lexer *lexer, const struct dictionary *dict, struct cmd_examine *cmd);
const struct variable **vars, int n_vars,
const struct variable *id
) ;
const struct variable **vars, int n_vars,
const struct variable *id
) ;
-void box_plot_variables (const struct factor *fctr,
- const struct variable **vars, int n_vars,
+void box_plot_variables (const struct factor *fctr,
+ const struct variable **vars, int n_vars,
-void factor_calc (struct ccase *c, int case_no,
- double weight, int case_missing);
+void factor_calc (const struct ccase *c, int case_no,
+ double weight, int case_missing);
/* Represent a factor as a string, so it can be
printed in a human readable fashion */
/* Represent a factor as a string, so it can be
printed in a human readable fashion */
-const char * factor_to_string (const struct factor *fctr,
- struct factor_statistics *fs,
- const struct variable *var);
+const char * factor_to_string (const struct factor *fctr,
+ const struct factor_statistics *fs,
+ const struct variable *var);
/* Represent a factor as a string, so it can be
printed in a human readable fashion,
but sacrificing some readablility for the sake of brevity */
/* Represent a factor as a string, so it can be
printed in a human readable fashion,
but sacrificing some readablility for the sake of brevity */
show_extremes (dependent_vars, n_dependent_vars, 0, cmd.st_n);
show_extremes (dependent_vars, n_dependent_vars, 0, cmd.st_n);
{
box_plot_group (0, (const struct variable **) dependent_vars,
n_dependent_vars, cmd.v_id);
{
box_plot_group (0, (const struct variable **) dependent_vars,
n_dependent_vars, cmd.v_id);
{
struct normal_curve normal;
normal.N = totals[v].n;
normal.mean = totals[v].mean;
normal.stddev = totals[v].stddev;
{
struct normal_curve normal;
normal.N = totals[v].n;
normal.mean = totals[v].mean;
normal.stddev = totals[v].stddev;
show_extremes (dependent_vars, n_dependent_vars, fctr, cmd.st_n);
show_extremes (dependent_vars, n_dependent_vars, fctr, cmd.st_n);
box_plot_variables (fctr,
(const struct variable **) dependent_vars,
n_dependent_vars, cmd.v_id);
box_plot_variables (fctr,
(const struct variable **) dependent_vars,
n_dependent_vars, cmd.v_id);
{
struct normal_curve normal;
normal.N = (*fs)->m[v].n;
normal.mean = (*fs)->m[v].mean;
normal.stddev = (*fs)->m[v].stddev;
{
struct normal_curve normal;
normal.N = (*fs)->m[v].n;
normal.mean = (*fs)->m[v].mean;
normal.stddev = (*fs)->m[v].stddev;
else if ( lex_match_id (lexer, "ROUND"))
percentile_algorithm = PC_ROUND;
else if ( lex_match_id (lexer, "ROUND"))
percentile_algorithm = PC_ROUND;
percentile_algorithm = PC_EMPIRICAL;
else if ( lex_match_id (lexer, "AEMPIRICAL"))
percentile_algorithm = PC_EMPIRICAL;
else if ( lex_match_id (lexer, "AEMPIRICAL"))
static int
xmn_custom_total (struct lexer *lexer UNUSED, struct dataset *ds UNUSED, struct cmd_examine *p, void *aux UNUSED)
{
static int
xmn_custom_total (struct lexer *lexer UNUSED, struct dataset *ds UNUSED, struct cmd_examine *p, void *aux UNUSED)
{
{
msg (SE, _ ("%s and %s are mutually exclusive"),"TOTAL","NOTOTAL");
return 0;
{
msg (SE, _ ("%s and %s are mutually exclusive"),"TOTAL","NOTOTAL");
return 0;
{
msg (SE, _ ("%s and %s are mutually exclusive"),"TOTAL","NOTOTAL");
return 0;
{
msg (SE, _ ("%s and %s are mutually exclusive"),"TOTAL","NOTOTAL");
return 0;
Returns 1 on success */
static int
xmn_custom_variables (struct lexer *lexer, struct dataset *ds, struct cmd_examine *cmd, void *aux UNUSED)
Returns 1 on success */
static int
xmn_custom_variables (struct lexer *lexer, struct dataset *ds, struct cmd_examine *cmd, void *aux UNUSED)
if (!parse_variables (lexer, dict, &dependent_vars, &n_dependent_vars,
PV_NO_DUPLICATE | PV_NUMERIC | PV_NO_SCRATCH) )
{
if (!parse_variables (lexer, dict, &dependent_vars, &n_dependent_vars,
PV_NO_DUPLICATE | PV_NUMERIC | PV_NO_SCRATCH) )
{
-void populate_percentiles (struct tab_table *tbl, int col, int row,
+void populate_percentiles (struct tab_table *tbl, int col, int row,
-void populate_descriptives (struct tab_table *t, int col, int row,
+void populate_descriptives (struct tab_table *t, int col, int row,
-void populate_extremes (struct tab_table *t, int col, int row, int n,
+void populate_extremes (struct tab_table *t, int col, int row, int n,
const struct metrics *m);
void populate_summary (struct tab_table *t, int col, int row,
const struct metrics *m);
void populate_summary (struct tab_table *t, int col, int row,
-factor_calc (struct ccase *c, int case_no, double weight, int case_missing)
+factor_calc (const struct ccase *c, int case_no, double weight,
+ int case_missing)
- indep_vals[0] = * case_data (c, fctr->indep_var[0]->fv);
+ indep_vals[0] = value_dup (
+ case_data (c, fctr->indep_var[0]),
+ var_get_width (fctr->indep_var[0])
+ );
- if ( fctr->indep_var[1] )
- indep_vals[1] = * case_data (c, fctr->indep_var[1]->fv);
+ if ( fctr->indep_var[1] )
+ indep_vals[1] = value_dup (
+ case_data (c, fctr->indep_var[1]),
+ var_get_width (fctr->indep_var[1])
+ );
metrics_calc ( & (*foo)->m[v], val, weight, case_no);
metrics_calc ( & (*foo)->m[v], val, weight, case_no);
void *cmd_, const struct dataset *ds)
{
struct dictionary *dict = dataset_dict (ds);
void *cmd_, const struct dataset *ds)
{
struct dictionary *dict = dataset_dict (ds);
metrics_precalc (&totals[v]);
for (r = casefile_get_reader (cf, NULL);
casereader_read (r, &c) ;
metrics_precalc (&totals[v]);
for (r = casefile_get_reader (cf, NULL);
casereader_read (r, &c) ;
metrics_calc (&totals[v], val, weight, case_no);
metrics_calc (&totals[v], val, weight, case_no);
}
factor_calc (&c, case_no, weight, case_missing);
}
factor_calc (&c, case_no, weight, case_missing);
fs->m[v].ptile_hash = list_to_ptile_hash (&percentile_list);
fs->m[v].ptile_alg = percentile_algorithm;
metrics_postcalc (&fs->m[v]);
fs->m[v].ptile_hash = list_to_ptile_hash (&percentile_list);
fs->m[v].ptile_alg = percentile_algorithm;
metrics_postcalc (&fs->m[v]);
idh0 = hsh_create (4, (hsh_compare_func *) compare_values,
(hsh_hash_func *) hash_value,
0,0);
idh0 = hsh_create (4, (hsh_compare_func *) compare_values,
(hsh_hash_func *) hash_value,
0,0);
hsh_probe (fctr->fstats, (void *) &key );
if ( !*ffs ) {
size_t i;
(*ffs) = create_factor_statistics (n_dependent_vars,
&key[0], &key[1]);
hsh_probe (fctr->fstats, (void *) &key );
if ( !*ffs ) {
size_t i;
(*ffs) = create_factor_statistics (n_dependent_vars,
&key[0], &key[1]);
tab_headers (tbl, heading_columns, 0, heading_rows, 0);
tab_dim (tbl, tab_natural_dimensions);
tab_headers (tbl, heading_columns, 0, heading_rows, 0);
tab_dim (tbl, tab_natural_dimensions);
- tab_joint_text (tbl, heading_columns, 0,
+
+ tab_joint_text (tbl, heading_columns, 0,
- tab_text (tbl, heading_columns + i*2 , 2, TAB_CENTER | TAT_TITLE,
+ tab_text (tbl, heading_columns + i*2 , 2, TAB_CENTER | TAT_TITLE,
- tab_text (tbl, heading_columns + i*2 + 1, 2, TAB_CENTER | TAT_TITLE,
+ tab_text (tbl, heading_columns + i*2 + 1, 2, TAB_CENTER | TAT_TITLE,
_ ("Percent"));
tab_joint_text (tbl, heading_columns + i*2 , 1,
_ ("Percent"));
tab_joint_text (tbl, heading_columns + i*2 , 1,
- tab_text (tbl, 1, heading_rows - 1, TAB_CENTER | TAT_TITLE,
+ tab_text (tbl, 1, heading_rows - 1, TAB_CENTER | TAT_TITLE,
- tab_text (tbl, 2, heading_rows - 1, TAB_CENTER | TAT_TITLE,
+ tab_text (tbl, 2, heading_rows - 1, TAB_CENTER | TAT_TITLE,
tab_hline (tbl, TAL_1, 0, n_cols -1 , i * n_factors + heading_rows);
tab_hline (tbl, TAL_1, 0, n_cols -1 , i * n_factors + heading_rows);
- static union value prev;
-
- if ( 0 != compare_values (&prev, & (*fs)->id[0],
- fctr->indep_var[0]->width))
+ if ( !prev ||
+ 0 != compare_values (prev, (*fs)->id[0],
+ var_get_width (fctr->indep_var[0])))
- if (fctr->indep_var[1] && count > 0 )
- tab_hline (tbl, TAL_1, 1, n_cols - 1,
+ if (fctr->indep_var[1] && count > 0 )
+ tab_hline (tbl, TAL_1, 1, n_cols - 1,
- populate_summary (tbl, heading_columns,
- (i * n_factors) + count
+ populate_summary (tbl, heading_columns,
+ (i * n_factors) + count
populate_summary (struct tab_table *t, int col, int row,
const struct metrics *m)
{
populate_summary (struct tab_table *t, int col, int row,
const struct metrics *m)
{
tab_float (t, col + 0, row + 0, TAB_RIGHT, m->n, 8, 0);
tab_float (t, col + 2, row + 0, TAB_RIGHT, m->n_missing, 8, 0);
tab_float (t, col + 0, row + 0, TAB_RIGHT, m->n, 8, 0);
tab_float (t, col + 2, row + 0, TAB_RIGHT, m->n_missing, 8, 0);
- tab_text (t, col + 1, row + 0, TAB_RIGHT | TAT_PRINTF, "%2.0f%%",
+ tab_text (t, col + 1, row + 0, TAB_RIGHT | TAT_PRINTF, "%2.0f%%",
- tab_text (t, col + 3, row + 0, TAB_RIGHT | TAT_PRINTF, "%2.0f%%",
+ tab_text (t, col + 3, row + 0, TAB_RIGHT | TAT_PRINTF, "%2.0f%%",
- tab_text (t, col + 5, row + 0, TAB_RIGHT | TAT_PRINTF, "%2.0f%%",
+ tab_text (t, col + 5, row + 0, TAB_RIGHT | TAT_PRINTF, "%2.0f%%",
tab_headers (tbl, heading_columns, 0, heading_rows, 0);
tab_dim (tbl, tab_natural_dimensions);
tab_headers (tbl, heading_columns, 0, heading_rows, 0);
tab_dim (tbl, tab_natural_dimensions);
tab_vline (tbl, TAL_2, n_cols - 2, 0, n_rows -1);
tab_vline (tbl, TAL_1, n_cols - 1, 0, n_rows -1);
tab_vline (tbl, TAL_2, n_cols - 2, 0, n_rows -1);
tab_vline (tbl, TAL_1, n_cols - 1, 0, n_rows -1);
- tab_text (tbl, 1, heading_rows - 1, TAB_CENTER | TAT_TITLE,
+ tab_text (tbl, 1, heading_rows - 1, TAB_CENTER | TAT_TITLE,
- if ( fctr->indep_var[1] )
- tab_text (tbl, 2, heading_rows - 1, TAB_CENTER | TAT_TITLE,
+ if ( fctr->indep_var[1] )
+ tab_text (tbl, 2, heading_rows - 1, TAB_CENTER | TAT_TITLE,
var_to_string (fctr->indep_var[1]));
}
tab_text (tbl, n_cols - 1, 0, TAB_CENTER | TAT_TITLE, _ ("Value"));
tab_text (tbl, n_cols - 2, 0, TAB_CENTER | TAT_TITLE, _ ("Case Number"));
var_to_string (fctr->indep_var[1]));
}
tab_text (tbl, n_cols - 1, 0, TAB_CENTER | TAT_TITLE, _ ("Value"));
tab_text (tbl, n_cols - 2, 0, TAB_CENTER | TAT_TITLE, _ ("Case Number"));
- if ( i > 0 )
- tab_hline (tbl, TAL_1, 0, n_cols -1 ,
+ if ( i > 0 )
+ tab_hline (tbl, TAL_1, 0, n_cols -1 ,
i * 2 * n_extremities * n_factors + heading_rows,
n_extremities, &totals[i]);
i * 2 * n_extremities * n_factors + heading_rows,
n_extremities, &totals[i]);
- if ( 0 != compare_values (&prev, & (*fs)->id[0],
- fctr->indep_var[0]->width))
+ if ( !prev || 0 != compare_values (prev, (*fs)->id[0],
+ var_get_width (fctr->indep_var[0])))
tab_hline (tbl, TAL_1, 1, n_cols - 1, row);
tab_hline (tbl, TAL_1, 1, n_cols - 1, row);
tab_hline (tbl, TAL_1, 2, n_cols - 1, row);
tab_hline (tbl, TAL_1, 2, n_cols - 1, row);
int col, int row, int n, const struct metrics *m)
{
int extremity;
int col, int row, int n, const struct metrics *m)
{
int extremity;
tab_hline (t, TAL_1, col, col + 3, row + n );
tab_hline (t, TAL_1, col, col + 3, row + n );
{
/* Highest */
tab_float (t, col + 1, row + extremity,
{
/* Highest */
tab_float (t, col + 1, row + extremity,
break ;
tab_float (t, col + 3, row + extremity + j + n,
break ;
tab_float (t, col + 3, row + extremity + j + n,
break ;
tab_float (t, col + 3, row + extremity + j,
break ;
tab_float (t, col + 3, row + extremity + j,
tab_dim (tbl, tab_natural_dimensions);
/* Outline the box and have no internal lines*/
tab_dim (tbl, tab_natural_dimensions);
/* Outline the box and have no internal lines*/
- tab_text (tbl, 1, heading_rows - 1, TAB_CENTER | TAT_TITLE,
+ tab_text (tbl, 1, heading_rows - 1, TAB_CENTER | TAT_TITLE,
- tab_text (tbl, 2, heading_rows - 1, TAB_CENTER | TAT_TITLE,
+ tab_text (tbl, 2, heading_rows - 1, TAB_CENTER | TAT_TITLE,
- if ( 0 != compare_values (&prev, & (*fs)->id[0],
- fctr->indep_var[0]->width))
+ if ( !prev || 0 != compare_values (prev, (*fs)->id[0],
+ var_get_width (fctr->indep_var[0])))
tab_hline (tbl, TAL_1, 1, n_cols - 1, row);
tab_hline (tbl, TAL_1, 1, n_cols - 1, row);
tab_hline (tbl, TAL_1, 2, n_cols - 1, row);
tab_hline (tbl, TAL_1, 2, n_cols - 1, row);
-populate_descriptives (struct tab_table *tbl, int col, int row,
+populate_descriptives (struct tab_table *tbl, int col, int row,
row + 1,
TAB_LEFT | TAT_TITLE | TAT_PRINTF,
_ ("%g%% Confidence Interval for Mean"), cmd.n_cinterval[0]);
row + 1,
TAB_LEFT | TAT_TITLE | TAT_PRINTF,
_ ("%g%% Confidence Interval for Mean"), cmd.n_cinterval[0]);
-box_plot_variables (const struct factor *fctr,
- const struct variable **vars, int n_vars,
+box_plot_variables (const struct factor *fctr,
+ const struct variable **vars, int n_vars,
{
box_plot_group (fctr, vars, n_vars, id);
return;
}
{
box_plot_group (fctr, vars, n_vars, id);
return;
}
{
y_max = MAX (y_max, (*fs)->m[i].max);
y_min = MIN (y_min, (*fs)->m[i].min);
}
{
y_max = MAX (y_max, (*fs)->m[i].max);
y_min = MIN (y_min, (*fs)->m[i].min);
}
-box_plot_group (const struct factor *fctr,
- const struct variable **vars,
+box_plot_group (const struct factor *fctr,
+ const struct variable **vars,
chart_write_title (ch, _ ("Boxplot"));
boxplot_draw_boxplot (ch,
chart_write_title (ch, _ ("Boxplot"));
boxplot_draw_boxplot (ch,
factorname);
chart_write_xlabel (dnp_chart, _ ("Observed Value"));
chart_write_ylabel (dnp_chart, _ ("Dev from Normal"));
factorname);
chart_write_xlabel (dnp_chart, _ ("Observed Value"));
chart_write_ylabel (dnp_chart, _ ("Dev from Normal"));
chart_write_yscale (np_chart, yfirst, ylast, 5);
{
chart_write_yscale (np_chart, yfirst, ylast, 5);
{
find its limits before we can plot it */
double *d_data = xnmalloc (m->n_data, sizeof *d_data);
double d_max = -DBL_MAX;
double d_min = DBL_MAX;
find its limits before we can plot it */
double *d_data = xnmalloc (m->n_data, sizeof *d_data);
double d_max = -DBL_MAX;
double d_min = DBL_MAX;
{
const double ns = gsl_cdf_ugaussian_Pinv (m->wvp[i]->rank / ( m->n + 1));
chart_datum (np_chart, 0, m->wvp[i]->v.f, ns);
d_data[i] = (m->wvp[i]->v.f - m->mean) / m->stddev - ns;
{
const double ns = gsl_cdf_ugaussian_Pinv (m->wvp[i]->rank / ( m->n + 1));
chart_datum (np_chart, 0, m->wvp[i]->v.f, ns);
d_data[i] = (m->wvp[i]->v.f - m->mean) / m->stddev - ns;
if ( d_data[i] < d_min ) d_min = d_data[i];
if ( d_data[i] > d_max ) d_max = d_data[i];
}
chart_write_yscale (dnp_chart, d_min, d_max, 5);
if ( d_data[i] < d_min ) d_min = d_data[i];
if ( d_data[i] > d_max ) d_max = d_data[i];
}
chart_write_yscale (dnp_chart, d_min, d_max, 5);
chart_datum (dnp_chart, 0, m->wvp[i]->v.f, d_data[i]);
free (d_data);
chart_datum (dnp_chart, 0, m->wvp[i]->v.f, d_data[i]);
free (d_data);
tab_dim (tbl, tab_natural_dimensions);
/* Outline the box and have no internal lines*/
tab_dim (tbl, tab_natural_dimensions);
/* Outline the box and have no internal lines*/
tab_hline (tbl, TAL_1, n_heading_columns, n_cols - 1, 1 );
tab_hline (tbl, TAL_1, n_heading_columns, n_cols - 1, 1 );
- tab_float (tbl, n_heading_columns + i++ , 1,
+ tab_float (tbl, n_heading_columns + i++ , 1,
- tab_text (tbl, 1, n_heading_rows - 1,
- TAB_CENTER | TAT_TITLE,
+ tab_text (tbl, 1, n_heading_rows - 1,
+ TAB_CENTER | TAT_TITLE,
- tab_text (tbl, 2, n_heading_rows - 1, TAB_CENTER | TAT_TITLE,
+ tab_text (tbl, 2, n_heading_rows - 1, TAB_CENTER | TAT_TITLE,
- if ( 0 != compare_values (&prev, & (*fs)->id[0],
- fctr->indep_var[0]->width))
+ if ( !prev || 0 != compare_values (prev, (*fs)->id[0],
+ var_get_width (fctr->indep_var[0])))
tab_hline (tbl, TAL_1, 1, n_cols - 1, row);
tab_hline (tbl, TAL_1, 1, n_cols - 1, row);
tab_hline (tbl, TAL_1, 2, n_cols - 1, row);
tab_hline (tbl, TAL_1, 2, n_cols - 1, row);
-populate_percentiles (struct tab_table *tbl, int col, int row,
+populate_percentiles (struct tab_table *tbl, int col, int row,
- tab_float (tbl, col + i + 1 , row,
+ tab_float (tbl, col + i + 1 , row,
- if ( (*p)->p == 25 )
- tab_float (tbl, col + i + 1 , row + 1,
+ if ( (*p)->p == 25 )
+ tab_float (tbl, col + i + 1 , row + 1,
- if ( (*p)->p == 50 )
- tab_float (tbl, col + i + 1 , row + 1,
+ if ( (*p)->p == 50 )
+ tab_float (tbl, col + i + 1 , row + 1,
- if ( (*p)->p == 75 )
- tab_float (tbl, col + i + 1 , row + 1,
+ if ( (*p)->p == 75 )
+ tab_float (tbl, col + i + 1 , row + 1,
-factor_to_string (const struct factor *fctr,
- struct factor_statistics *fs,
- const struct variable *var)
+factor_to_string (const struct factor *fctr,
+ const struct factor_statistics *fs,
+ const struct variable *var)
snprintf (buf2, 100, "%s = %s",
var_to_string (fctr->indep_var[0]),
snprintf (buf2, 100, "%s = %s",
var_to_string (fctr->indep_var[0]),
{
sprintf (buf2, "; %s = %s)",
var_to_string (fctr->indep_var[1]),
{
sprintf (buf2, "; %s = %s)",
var_to_string (fctr->indep_var[1]),
char buf2[100];
snprintf (buf, 100, "%s",
char buf2[100];
snprintf (buf, 100, "%s",
- value_to_string (&fs->id[0], fctr->indep_var[0]));
-
- if ( fctr->indep_var[1] )
+ var_get_value_name (fctr->indep_var[0], fs->id[0]));
+
+ if ( fctr->indep_var[1] )
- sprintf (buf2, ",%s)", value_to_string (&fs->id[1], fctr->indep_var[1]) );
+ sprintf (buf2, ",%s)", var_get_value_name (fctr->indep_var[1],
+ fs->id[1]) );