projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
pivot-table: New functions for setting captions, etc.
[pspp]
/
src
/
language
/
stats
/
wilcoxon.c
diff --git
a/src/language/stats/wilcoxon.c
b/src/language/stats/wilcoxon.c
index 230e97df57f74ac51be8f7967c7f7ef74ee79d5e..775e63ef4adbe582c517a26da453d4d1a15c334b 100644
(file)
--- a/
src/language/stats/wilcoxon.c
+++ b/
src/language/stats/wilcoxon.c
@@
-49,7
+49,7
@@
append_difference (const struct ccase *c, casenumber n UNUSED, void *aux)
{
const variable_pair *vp = aux;
{
const variable_pair *vp = aux;
- return case_
data (c, (*vp)[0])->f - case_data (c, (*vp)[1])->f
;
+ return case_
num (c, (*vp)[0]) - case_num (c, (*vp)[1])
;
}
static void show_ranks_box (const struct wilcoxon_state *,
}
static void show_ranks_box (const struct wilcoxon_state *,
@@
-85,7
+85,7
@@
wilcoxon_execute (const struct dataset *ds,
const struct dictionary *dict = dataset_dict (ds);
const struct two_sample_test *t2s = UP_CAST (test, const struct two_sample_test, parent);
const struct dictionary *dict = dataset_dict (ds);
const struct two_sample_test *t2s = UP_CAST (test, const struct two_sample_test, parent);
- struct wilcoxon_state *ws =
xcalloc (t2s->n_pairs, sizeof *ws
);
+ struct wilcoxon_state *ws =
XCALLOC (t2s->n_pairs, struct wilcoxon_state
);
const struct variable *weight = dict_get_weight (dict);
struct variable *weightx = dict_create_internal_var (WEIGHT_IDX, 0);
struct caseproto *proto;
const struct variable *weight = dict_get_weight (dict);
struct variable *weightx = dict_create_internal_var (WEIGHT_IDX, 0);
struct caseproto *proto;
@@
-99,7
+99,7
@@
wilcoxon_execute (const struct dataset *ds,
if (weight != NULL)
proto = caseproto_add_width (proto, 0);
if (weight != NULL)
proto = caseproto_add_width (proto, 0);
- for (i = 0 ; i < t2s->n_pairs; ++i
)
+ for (i = 0 ; i < t2s->n_pairs; ++i)
{
struct casereader *r = casereader_clone (input);
struct casewriter *writer;
{
struct casereader *r = casereader_clone (input);
struct casewriter *writer;
@@
-124,19
+124,14
@@
wilcoxon_execute (const struct dataset *ds,
double d = append_difference (c, 0, vp);
if (d > 0)
double d = append_difference (c, 0, vp);
if (d > 0)
- {
- case_data_rw (output, ws[i].sign)->f = 1.0;
-
- }
+ *case_num_rw (output, ws[i].sign) = 1.0;
else if (d < 0)
else if (d < 0)
- {
- case_data_rw (output, ws[i].sign)->f = -1.0;
- }
+ *case_num_rw (output, ws[i].sign) = -1.0;
else
{
double w = 1.0;
if (weight)
else
{
double w = 1.0;
if (weight)
- w = case_
data (c, weight)->f
;
+ w = case_
num (c, weight)
;
/* Central point values should be dropped */
ws[i].n_zeros += w;
/* Central point values should be dropped */
ws[i].n_zeros += w;
@@
-144,10
+139,10
@@
wilcoxon_execute (const struct dataset *ds,
continue;
}
continue;
}
-
case_data_rw (output, ws[i].absdiff)->f
= fabs (d);
+
*case_num_rw (output, ws[i].absdiff)
= fabs (d);
if (weight)
if (weight)
-
case_data_rw (output, weightx)->f = case_data (c, weight)->f
;
+
*case_num_rw (output, weightx) = case_num (c, weight)
;
casewriter_write (writer, output);
}
casewriter_write (writer, output);
}
@@
-156,7
+151,7
@@
wilcoxon_execute (const struct dataset *ds,
}
caseproto_unref (proto);
}
caseproto_unref (proto);
- for (i = 0 ; i < t2s->n_pairs; ++i
)
+ for (i = 0 ; i < t2s->n_pairs; ++i)
{
struct casereader *rr ;
struct ccase *c;
{
struct casereader *rr ;
struct ccase *c;
@@
-165,17
+160,15
@@
wilcoxon_execute (const struct dataset *ds,
rr = casereader_create_append_rank (ws[i].reader, ws[i].absdiff,
weight ? weightx : NULL, &err,
distinct_callback, &ws[i]
rr = casereader_create_append_rank (ws[i].reader, ws[i].absdiff,
weight ? weightx : NULL, &err,
distinct_callback, &ws[i]
-
);
+ );
for (; (c = casereader_read (rr)) != NULL; case_unref (c))
{
for (; (c = casereader_read (rr)) != NULL; case_unref (c))
{
- double sign = case_data (c, ws[i].sign)->f;
- double rank = case_data_idx (c, weight ? 3 : 2)->f;
- double w = 1.0;
- if (weight)
- w = case_data (c, weightx)->f;
+ double sign = case_num (c, ws[i].sign);
+ double rank = case_num_idx (c, weight ? 3 : 2);
+ double w = weight ? case_num (c, weightx) : 1.0;
- if (
sign > 0
)
+ if (
sign > 0
)
{
ws[i].positives.sum += rank * w;
ws[i].positives.n += w;
{
ws[i].positives.sum += rank * w;
ws[i].positives.n += w;
@@
-199,7
+192,7
@@
wilcoxon_execute (const struct dataset *ds,
show_ranks_box (ws, t2s, dict);
show_tests_box (ws, t2s, exact, timer);
show_ranks_box (ws, t2s, dict);
show_tests_box (ws, t2s, exact, timer);
- for (i = 0 ; i < t2s->n_pairs; ++i
)
+ for (i = 0 ; i < t2s->n_pairs; ++i)
{
dict_destroy_internal_var (ws[i].sign);
dict_destroy_internal_var (ws[i].absdiff);
{
dict_destroy_internal_var (ws[i].sign);
dict_destroy_internal_var (ws[i].absdiff);