X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fstats%2Fchisquare.c;h=d1d81bab39dcc26e422aa32e96354c5c16a808d5;hb=18cbae3479d770c1f517ee2ccc060c7457f2a0d7;hp=df540651d7541b6beb56a94cdb20408cbc57056e;hpb=5cab4cf3322f29c0ed7134d23740e07382914f20;p=pspp diff --git a/src/language/stats/chisquare.c b/src/language/stats/chisquare.c index df540651d7..d1d81bab39 100644 --- a/src/language/stats/chisquare.c +++ b/src/language/stats/chisquare.c @@ -70,7 +70,7 @@ create_freq_hash_with_range (const struct dictionary *dict, /* Populate the hash with zero entries */ entries = xnmalloc (hi - lo + 1, sizeof *entries); - for (i_d = lo; i_d <= hi; i_d += 1.0 ) + for (i_d = lo; i_d <= hi; i_d += 1.0) { size_t ofs = i_d - lo; union value value = { i_d }; @@ -141,16 +141,16 @@ chisquare_execute (const struct dataset *ds, struct one_sample_test *ost = &cst->parent; double total_expected = 0.0; - double *df = xzalloc (sizeof (*df) * ost->n_vars); - double *xsq = xzalloc (sizeof (*df) * ost->n_vars); + double *df = XCALLOC (ost->n_vars, double); + double *xsq = XCALLOC (ost->n_vars, double); bool ok; - for ( i = 0 ; i < cst->n_expected ; ++i ) + for (i = 0 ; i < cst->n_expected ; ++i) total_expected += cst->expected[i]; - if ( cst->ranged == false ) + if (cst->ranged == false) { - for ( v = 0 ; v < ost->n_vars ; ++v ) + for (v = 0 ; v < ost->n_vars ; ++v) { const struct variable *var = ost->vars[v]; @@ -169,14 +169,14 @@ chisquare_execute (const struct dataset *ds, if (cst->n_expected > 0 && n_cells != cst->n_expected) { msg (ME, _("CHISQUARE test specified %d expected values, but " - "variable %s has %d distinct values."), + "variable %s has %zu distinct values."), cst->n_expected, var_get_name (var), n_cells); freq_hmap_destroy (&freq_hash, var_get_width (var)); continue; } struct pivot_table *table = pivot_table_create__ ( - pivot_value_new_variable (var)); + pivot_value_new_variable (var), "Chisquare"); pivot_table_set_weight_var (table, dict_get_weight (dict)); pivot_dimension_create ( @@ -244,19 +244,19 @@ chisquare_execute (const struct dataset *ds, struct pivot_dimension *var_dim = pivot_dimension_create (table, PIVOT_AXIS_COLUMN, N_("Variable")); - for ( size_t i = 0 ; i < ost->n_vars ; ++i ) + for (size_t i = 0 ; i < ost->n_vars ; ++i) pivot_category_create_leaf (var_dim->root, pivot_value_new_variable (ost->vars[i])); struct pivot_dimension *category_dim = pivot_dimension_create (table, PIVOT_AXIS_ROW, N_("Category")); size_t n_cells = cst->hi - cst->lo + 1; - for (size_t i = 0 ; i < n_cells; ++i ) + for (size_t i = 0 ; i < n_cells; ++i) pivot_category_create_leaf (category_dim->root, pivot_value_new_integer (i + 1)); pivot_category_create_leaves (category_dim->root, N_("Total")); - for ( size_t v = 0 ; v < ost->n_vars ; ++v ) + for (size_t v = 0 ; v < ost->n_vars ; ++v) { const struct variable *var = ost->vars[v]; struct casereader *reader = @@ -274,11 +274,11 @@ chisquare_execute (const struct dataset *ds, struct freq **ff = freq_hmap_sort (&freq_hash, var_get_width (var)); double total_obs = 0.0; - for ( size_t i = 0 ; i < hmap_count (&freq_hash) ; ++i ) + for (size_t i = 0 ; i < hmap_count (&freq_hash) ; ++i) total_obs += ff[i]->count; xsq[v] = 0.0; - for ( size_t i = 0 ; i < hmap_count (&freq_hash) ; ++i ) + for (size_t i = 0 ; i < hmap_count (&freq_hash) ; ++i) { /* Category. */ pivot_table_put3 (table, 0, v, i, @@ -327,7 +327,7 @@ chisquare_execute (const struct dataset *ds, struct pivot_dimension *variables = pivot_dimension_create ( table, PIVOT_AXIS_ROW, N_("Variable")); - for ( size_t v = 0 ; v < ost->n_vars ; ++v ) + for (size_t v = 0 ; v < ost->n_vars ; ++v) { const struct variable *var = ost->vars[v];