- tab_columns (t, SOM_COL_DOWN, 1);
- if (show_varname)
- {
- if (v->label)
- tab_title (t, 1, "%s: %s", v->name, v->label);
- else
- tab_title (t, 0, v->name);
- }
- else
- tab_flags (t, SOMF_NO_TITLE);
-
- tab_submit (t);
-}
-\f
-#if 0
-/* Statistical calculation. */
-
-static int degree[6];
-static int maxdegree, minmax;
-
-static void stat_func (struct freq *, VISIT, int);
-static void calc_stats (int);
-static void display_stats (int);
-
-/* mapping of data[]:
- * 0=>8
- * 1=>9
- * 2=>10
- * index 3: number of modes found (detects multiple modes)
- * index 4: number of nodes processed, for calculation of median
- * 5=>11
- *
- * mapping of dbl[]:
- * index 0-3: sum of X**i
- * index 4: minimum
- * index 5: maximum
- * index 6: mode
- * index 7: median
- * index 8: number of cases, valid and missing
- * index 9: number of valid cases
- * index 10: maximum frequency found, for calculation of mode
- * index 11: maximum frequency
- */
-static void
-out_stats (int i)
-{
- int j;
-
- if (cur_var->type == ALPHA)
- return;
- for (j = 0; j < 8; j++)
- cur_var->dbl[j] = 0.;
- cur_var->dbl[10] = 0;
- cur_var->dbl[4] = DBL_MAX;
- cur_var->dbl[5] = -DBL_MAX;
- for (j = 2; j < 5; j++)
- cur_var->data[j] = 0;
- cur_var->p.frq.median_ncases = cur_var->p.frq.t.valid_cases / 2;
- avlwalk (cur_var->p.frq.t.f, stat_func, LEFT_TO_RIGHT);
- calc_stats (i);
- display_stats (i);
-}
-
-static void
-calc_stats (int i)
-{
- struct variable *v;
- double n;
- double *d;
-
- v = v_variables[i];
- n = v->p.frq.t.valid_cases;
- d = v->dbl;
-
- if (n < 2 || (n < 3 && stat[FRQ_ST_7]))
- {
- warn (_("only %g case%s for variable %s, statistics not "
- "computed"), n, n == 1 ? "" : "s", v->name);
- return;
- }
- if (stat[FRQ_ST_9])
- v->res[FRQ_ST_9] = d[5] - d[4];
- if (stat[FRQ_ST_10])
- v->res[FRQ_ST_10] = d[4];
- if (stat[FRQ_ST_11])
- v->res[FRQ_ST_11] = d[5];
- if (stat[FRQ_ST_12])
- v->res[FRQ_ST_12] = d[0];
- if (stat[FRQ_ST_1] || stat[FRQ_ST_2] || stat[FRQ_ST_5] || stat[FRQ_ST_6] || stat[FRQ_ST_7])
- {
- v->res[FRQ_ST_1] = calc_mean (d, n);
- v->res[FRQ_ST_6] = calc_variance (d, n);
- }
- if (stat[FRQ_ST_2] || stat[FRQ_ST_5] || stat[FRQ_ST_7])
- v->res[FRQ_ST_5] = calc_stddev (v->res[FRQ_ST_6]);
- if (stat[FRQ_ST_2])
- v->res[FRQ_ST_2] = calc_semean (v->res[FRQ_ST_5], n);
- if (stat[FRQ_ST_7])
- {
- v->res[FRQ_ST_7] = calc_kurt (d, n, v->res[FRQ_ST_6]);
- v->res[FRQ_ST_14] = calc_sekurt (n);
- }
- if (stat[FRQ_ST_8])
- {
- v->res[FRQ_ST_8] = calc_skew (d, n, v->res[FRQ_ST_5]);
- v->res[FRQ_ST_15] = calc_seskew (n);
- }
- if (stat[FRQ_ST_MODE])
- {
- v->res[FRQ_ST_MODE] = v->dbl[6];
- if (v->data[3] > 1)
- warn (_("The variable %s has %d modes. The lowest of these "
- "is the one given in the table."), v->name, v->data[3]);
- }
- if (stat[FRQ_ST_MEDIAN])
- v->res[FRQ_ST_MEDIAN] = v->dbl[7];
-}
-
-static void
-stat_func (struct freq * x, VISIT order, int param)
-{
- double d, f;
-
- if (order != INORDER)
- return;
- f = d = x->v.f;
- cur_var->dbl[0] += (d * x->c);
- switch (maxdegree)
- {
- case 1:
- f *= d;
- cur_var->dbl[1] += (f * x->c);
- break;
- case 2:
- f *= d;
- cur_var->dbl[1] += (f * x->c);
- f *= d;
- cur_var->dbl[2] += (f * x->c);
- break;
- case 3:
- f *= d;
- cur_var->dbl[1] += (f * x->c);
- f *= d;
- cur_var->dbl[2] += (f * x->c);
- f *= d;
- cur_var->dbl[3] += (f * x->c);
- break;
- }
- if (minmax)
- {
- if (d < cur_var->dbl[4])
- cur_var->dbl[4] = d;
- if (d > cur_var->dbl[5])
- cur_var->dbl[5] = d;
- }
- if (x->c > cur_var->dbl[10])
- {
- cur_var->data[3] = 1;
- cur_var->dbl[10] = x->c;
- cur_var->dbl[6] = x->v.f;
- }
- else if (x->c == cur_var->dbl[10])
- cur_var->data[3]++;
- if (cur_var->data[4] < cur_var->p.frq.median_ncases
- && cur_var->data[4] + x->c >= cur_var->p.frq.median_ncases)
- cur_var->dbl[7] = x->v.f;
- cur_var->data[4] += x->c;
-}
-\f
-/* Statistical display. */
-static int column, ncolumns;
-
-static void outstat (char *, double);