/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 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
/* The comparison criterion */
enum comparison criterion;
- /* The width of the independent variable */
- int indep_width ;
+ /* The independent variable */
+ struct variable *indep_var;
union {
/* The value of the independent variable at which groups are determined to
static int mode;
-static struct cmd_t_test cmd;
-
-static bool bad_weight_warn = false;
-
-
static int compare_group_binary (const struct group_statistics *a,
const struct group_statistics *b,
const struct group_properties *p);
int
cmd_t_test (struct lexer *lexer, struct dataset *ds)
{
+ struct cmd_t_test cmd;
struct casegrouper *grouper;
struct casereader *group;
bool ok;
return CMD_FAILURE;
}
- bad_weight_warn = true;
-
/* Data pass. */
grouper = casegrouper_create_splits (proc_open (ds), dataset_dict (ds));
while (casegrouper_get_next_group (grouper, &group))
}
}
- if (!parse_value (lexer, &gp.v.g_value[0], var_get_type (indep_var)))
+ if (!parse_value (lexer, &gp.v.g_value[0], var_get_width (indep_var)))
return 0;
lex_match (lexer, ',');
return 1;
}
- if (!parse_value (lexer, &gp.v.g_value[1], var_get_type (indep_var)))
+ if (!parse_value (lexer, &gp.v.g_value[1], var_get_width (indep_var)))
return 0;
n_group_values = 2;
tab_headers (this->t,0,0,1,0);
tab_box (this->t, TAL_2, TAL_2, TAL_0, TAL_1, 0, 0, cols -1, rows -1 );
tab_hline (this->t, TAL_2,0,cols-1,1);
- tab_dim (this->t, tab_natural_dimensions);
+ tab_dim (this->t, tab_natural_dimensions, NULL);
}
void ssbox_one_sample_populate (struct ssbox *ssb,
const char *s;
s = var_lookup_value_label (indep_var, &gp.v.g_value[0]);
- val_lab[0] = s ? strdup (s) : NULL;
+ val_lab[0] = s ? xstrdup (s) : NULL;
s = var_lookup_value_label (indep_var, &gp.v.g_value[1]);
- val_lab[1] = s ? strdup (s) : NULL;
+ val_lab[1] = s ? xstrdup (s) : NULL;
}
else
{
- val_lab[0] = calloc (sizeof (char), MAX_SHORT_STRING + 1);
- val_lab[1] = calloc (sizeof (char), MAX_SHORT_STRING + 1);
+ val_lab[0] = xcalloc (sizeof (char), MAX_SHORT_STRING + 1);
+ val_lab[1] = xcalloc (sizeof (char), MAX_SHORT_STRING + 1);
memcpy (val_lab[0], gp.v.g_value[0].s, MAX_SHORT_STRING);
memcpy (val_lab[1], gp.v.g_value[1].s, MAX_SHORT_STRING);
}
tab_headers (self->t,0,0,3,0);
tab_box (self->t, TAL_2, TAL_2, TAL_0, TAL_0, 0, 0, cols -1, rows -1);
tab_hline (self->t, TAL_2,0,cols-1,3);
- tab_dim (self->t, tab_natural_dimensions);
+ tab_dim (self->t, tab_natural_dimensions, NULL);
}
tab_box (table, TAL_2, TAL_2, TAL_0, TAL_1, 0, 0, cols -1, rows -1 );
tab_hline (table, TAL_2, 0, cols - 1, 1);
tab_vline (table, TAL_2, 2, 0, rows - 1);
- tab_dim (table, tab_natural_dimensions);
+ tab_dim (table, tab_natural_dimensions, NULL);
tab_title (table, _ ("Paired Samples Correlations"));
/* column headings */
gs->n += weight;
gs->sum += weight * val->f;
- gs->ssq += weight * val->f * val->f;
+ gs->ssq += weight * pow2 (val->f);
}
}
return 0;
gs->mean=gs->sum / gs->n;
gs->s_std_dev= sqrt (
- ( (gs->ssq / gs->n ) - gs->mean * gs->mean )
+ ( (gs->ssq / gs->n ) - pow2 (gs->mean))
) ;
gs->std_dev= sqrt (
gs->n/ (gs->n-1) *
- ( (gs->ssq / gs->n ) - gs->mean * gs->mean )
+ ( (gs->ssq / gs->n ) - pow2 (gs->mean))
) ;
gs->se_mean = gs->std_dev / sqrt (gs->n);
/* There's always 2 groups for a T - TEST */
ttpr->n_groups = 2;
- gp.indep_width = var_get_width (indep_var);
+ gp.indep_var = indep_var;
ttpr->group_hash = hsh_create (2,
(hsh_compare_func *) compare_group_binary,
gs->mean = gs->sum / gs->n;
gs->s_std_dev= sqrt (
- ( (gs->ssq / gs->n ) - gs->mean * gs->mean )
+ ( (gs->ssq / gs->n ) - pow2 (gs->mean))
) ;
gs->std_dev= sqrt (
gs->n/ (gs->n-1) *
- ( (gs->ssq / gs->n ) - gs->mean * gs->mean )
+ ( (gs->ssq / gs->n ) - pow2 (gs->mean))
) ;
gs->se_mean = gs->std_dev / sqrt (gs->n);
struct casereader *pass1, *pass2, *pass3;
struct taint *taint;
- struct ccase c;
+ struct ccase *c;
enum mv_class exclude = cmd->miss != TTS_INCLUDE ? MV_ANY : MV_SYSTEM;
- if (!casereader_peek (input, 0, &c))
+ c = casereader_peek (input, 0);
+ if (c == NULL)
{
casereader_destroy (input);
return;
}
- output_split_file_values (ds, &c);
- case_destroy (&c);
+ output_split_file_values (ds, c);
+ case_unref (c);
if ( cmd->miss == TTS_LISTWISE )
input = casereader_create_filter_missing (input,
cmd->v_variables,
cmd->n_variables,
- exclude, NULL);
+ exclude, NULL, NULL);
input = casereader_create_filter_weight (input, dict, NULL, NULL);
casereader_split (input, &pass1, &pass2);
common_precalc (cmd);
- for (; casereader_read (pass1, &c); case_destroy (&c))
- common_calc (dict, &c, cmd, exclude);
+ for (; (c = casereader_read (pass1)) != NULL; case_unref (c))
+ common_calc (dict, c, cmd, exclude);
casereader_destroy (pass1);
common_postcalc (cmd);
{
case T_1_SAMPLE:
one_sample_precalc (cmd);
- for (; casereader_read (pass2, &c); case_destroy (&c))
- one_sample_calc (dict, &c, cmd, exclude);
+ for (; (c = casereader_read (pass2)) != NULL; case_unref (c))
+ one_sample_calc (dict, c, cmd, exclude);
one_sample_postcalc (cmd);
break;
case T_PAIRED:
paired_precalc (cmd);
- for (; casereader_read (pass2, &c); case_destroy (&c))
- paired_calc (dict, &c, cmd, exclude);
+ for (; (c = casereader_read (pass2)) != NULL; case_unref (c))
+ paired_calc (dict, c, cmd, exclude);
paired_postcalc (cmd);
break;
case T_IND_SAMPLES:
pass3 = casereader_clone (pass2);
group_precalc (cmd);
- for (; casereader_read (pass2, &c); case_destroy (&c))
- group_calc (dict, &c, cmd, exclude);
+ for (; (c = casereader_read (pass2)) != NULL; case_unref (c))
+ group_calc (dict, c, cmd, exclude);
group_postcalc (cmd);
levene (dict, pass3, indep_var, cmd->n_variables, cmd->v_variables,
if ( p->criterion == CMP_LE )
{
- /* less-than comparision is not meaningfull for
- alpha variables, so we shouldn't ever arrive here */
- assert (p->indep_width == 0 ) ;
-
flag_a = ( a->id.f < p->v.critical_value ) ;
flag_b = ( b->id.f < p->v.critical_value ) ;
}
if ( p->criterion == CMP_LE )
{
- /* Not meaningfull to do a less than compare for alpha values ? */
- assert (p->indep_width == 0 ) ;
flag = ( g->id.f < p->v.critical_value ) ;
}
else if ( p->criterion == CMP_EQ)
which_group (const struct group_statistics *g,
const struct group_properties *p)
{
- if ( 0 == compare_values (&g->id, &p->v.g_value[0], p->indep_width))
+ if ( 0 == compare_values_short (&g->id, &p->v.g_value[0], p->indep_var))
return 0;
- if ( 0 == compare_values (&g->id, &p->v.g_value[1], p->indep_width))
+ if ( 0 == compare_values_short (&g->id, &p->v.g_value[1], p->indep_var))
return 1;
return 2;