projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add code to read character encoding to dissect-sysfile.
[pspp]
/
src
/
language
/
stats
/
frequencies.q
diff --git
a/src/language/stats/frequencies.q
b/src/language/stats/frequencies.q
index e7509052b05b2aa93dfadbe3eb72a6cc97383e35..cd370be821c8db73f2d88da8350613a7ea8c07b0 100644
(file)
--- a/
src/language/stats/frequencies.q
+++ b/
src/language/stats/frequencies.q
@@
-1,5
+1,5
@@
/* PSPP - a program for statistical analysis.
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2007 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2007
, 2009
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 published by
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@
-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);
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);
freq_tab_to_hist(const struct freq_tab *ft, const struct variable *var);
@@
-376,11
+376,11
@@
internal_cmd_frequencies (struct lexer *lexer, struct dataset *ds)
for (; casegrouper_get_next_group (grouper, &group);
casereader_destroy (group))
{
for (; casegrouper_get_next_group (grouper, &group);
casereader_destroy (group))
{
- struct ccase c;
+ struct ccase
*
c;
precalc (group, ds);
precalc (group, ds);
- for (;
casereader_read (group, &c); case_destroy (&
c))
- calc (
&
c, ds);
+ for (;
(c = casereader_read (group)) != NULL; case_unref (
c))
+ calc (c, ds);
postcalc ();
}
ok = casegrouper_destroy (grouper);
postcalc ();
}
ok = casegrouper_destroy (grouper);
@@
-535,13
+535,14
@@
calc (const struct ccase *c, const struct dataset *ds)
static void
precalc (struct casereader *input, struct dataset *ds)
{
static void
precalc (struct casereader *input, struct dataset *ds)
{
- struct ccase c;
+ struct ccase
*
c;
size_t i;
size_t i;
- if (casereader_peek (input, 0, &c))
+ c = casereader_peek (input, 0);
+ if (c != NULL)
{
{
- output_split_file_values (ds,
&
c);
- case_
destroy (&
c);
+ output_split_file_values (ds, c);
+ case_
unref (
c);
}
pool_destroy (data_pool);
}
pool_destroy (data_pool);
@@
-606,31
+607,26
@@
postcalc (void)
if ( chart == GFT_HIST)
{
double d[frq_n_stats];
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);
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);
}
if ( chart == GFT_PIE)
{
do_piechart(v_variables[i], ft);
}
-
-
cleanup_freq_tab (v);
}
cleanup_freq_tab (v);
}
@@
-1437,14
+1433,14
@@
dump_statistics (const struct variable *v, int show_varname)
/* Create a gsl_histogram from a freq_tab */
/* 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;
{
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;
const double bins = 11;
struct hsh_iterator hi;
@@
-1461,15
+1457,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 ;
}
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];
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,6
+1495,7
@@
freq_tab_to_slice_array(const struct freq_tab *frq_tab,
{
const struct freq *frq = &frq_tab->valid[i];
{
const struct freq *frq = &frq_tab->valid[i];
+ ds_init_empty (&slices[i].label);
var_append_value_name (var, frq->value, &slices[i].label);
slices[i].magnetude = frq->count;
}
var_append_value_name (var, frq->value, &slices[i].label);
slices[i].magnetude = frq->count;
}