X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fstats%2Ffrequencies.q;h=94b2bcf9e6edd2303632342d6fa8e80304c62018;hb=c1f796a012aa172cf44ed3cf386b0222fa12ab35;hp=ef4769b60e17339f9133f394e93ea3415d5cf20f;hpb=23ce39ab4b18e1c86694c3fb9a69e99e48c4c3b0;p=pspp-builds.git diff --git a/src/language/stats/frequencies.q b/src/language/stats/frequencies.q index ef4769b6..94b2bcf9 100644 --- a/src/language/stats/frequencies.q +++ b/src/language/stats/frequencies.q @@ -268,7 +268,7 @@ static hsh_compare_func compare_freq_numeric_d, compare_freq_alpha_d; static void do_piechart(const struct variable *var, const struct freq_tab *frq_tab); -gsl_histogram * +struct histogram * freq_tab_to_hist(const struct freq_tab *ft, const struct variable *var); @@ -606,31 +606,26 @@ postcalc (void) if ( chart == GFT_HIST) { double d[frq_n_stats]; - struct normal_curve norm; - gsl_histogram *hist ; - - - norm.N = vf->tab.valid_cases; + struct histogram *hist ; calc_stats (v, d); - norm.mean = d[frq_mean]; - norm.stddev = d[frq_stddev]; - hist = freq_tab_to_hist(ft,v); + hist = freq_tab_to_hist (ft,v); - histogram_plot(hist, var_to_string(v), &norm, normal); + histogram_plot_n (hist, var_to_string(v), + vf->tab.valid_cases, + d[frq_mean], + d[frq_stddev], + normal); - gsl_histogram_free(hist); + statistic_destroy ((struct statistic *)hist); } - if ( chart == GFT_PIE) { do_piechart(v_variables[i], ft); } - - cleanup_freq_tab (v); } @@ -766,7 +761,7 @@ frq_custom_variables (struct lexer *lexer, struct dataset *ds, struct cmd_freque vf->groups = NULL; vf->width = var_get_width (v); vf->print = *var_get_print_format (v); - if (vf->width > MAX_SHORT_STRING && get_algorithm () == COMPATIBLE) + if (vf->width > MAX_SHORT_STRING && settings_get_algorithm () == COMPATIBLE) { enum fmt_type type = var_get_print_format (v)->type; vf->width = MAX_SHORT_STRING; @@ -1257,7 +1252,7 @@ calc_stats (const struct variable *v, double d[frq_n_stats]) double tp; if ( percentiles[i].flag2 ) continue ; - if ( get_algorithm() != COMPATIBLE ) + if ( settings_get_algorithm () != COMPATIBLE ) tp = (ft->valid_cases - 1) * percentiles[i].p; else @@ -1308,7 +1303,7 @@ calc_stats (const struct variable *v, double d[frq_n_stats]) double s; double dummy; - if ( get_algorithm() != COMPATIBLE ) + if ( settings_get_algorithm () != COMPATIBLE ) { s = modf((ft->valid_cases - 1) * percentiles[i].p , &dummy); } @@ -1437,14 +1432,14 @@ dump_statistics (const struct variable *v, int show_varname) /* Create a gsl_histogram from a freq_tab */ -gsl_histogram * -freq_tab_to_hist(const struct freq_tab *ft, const struct variable *var) +struct histogram * +freq_tab_to_hist (const struct freq_tab *ft, const struct variable *var) { int i; double x_min = DBL_MAX; double x_max = -DBL_MAX; - gsl_histogram *hist; + struct statistic *hist; const double bins = 11; struct hsh_iterator hi; @@ -1461,15 +1456,15 @@ freq_tab_to_hist(const struct freq_tab *ft, const struct variable *var) if ( frq->value[0].f > x_max ) x_max = frq->value[0].f ; } - hist = histogram_create(bins, x_min, x_max); + hist = histogram_create (bins, x_min, x_max); for( i = 0 ; i < ft->n_valid ; ++i ) { frq = &ft->valid[i]; - gsl_histogram_accumulate(hist, frq->value[0].f, frq->count); + histogram_add ((struct histogram *)hist, frq->value[0].f, frq->count); } - return hist; + return (struct histogram *)hist; } @@ -1499,7 +1494,8 @@ freq_tab_to_slice_array(const struct freq_tab *frq_tab, { const struct freq *frq = &frq_tab->valid[i]; - slices[i].label = var_get_value_name (var, frq->value); + ds_init_empty (&slices[i].label); + var_append_value_name (var, frq->value, &slices[i].label); slices[i].magnetude = frq->count; } @@ -1513,12 +1509,17 @@ static void do_piechart(const struct variable *var, const struct freq_tab *frq_tab) { struct slice *slices; - int n_slices; + int n_slices, i; slices = freq_tab_to_slice_array(frq_tab, var, &n_slices); piechart_plot(var_to_string(var), slices, n_slices); + for (i = 0 ; i < n_slices ; ++i ) + { + ds_destroy (&slices[i].label); + } + free(slices); }