67fd5f520ebcbf52ff54c5293959b38da312aa95
[pspp] / src / factor_stats.h
1 /* PSPP - A program for statistical analysis . -*-c-*-
2
3 Copyright (C) 2004 Free Software Foundation, Inc.
4 Author: John Darrington 2004
5
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License as
8 published by the Free Software Foundation; either version 2 of the
9 License, or (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 02111-1307, USA. */
20
21 #ifndef FACTOR_STATS
22 #define FACTOR_STATS
23
24
25 /* FIXME: These things should probably be amalgamated with the 
26    group_statistics struct */
27
28
29 struct metrics
30 {
31   double n;
32   
33   double ssq;
34   
35   double sum;
36
37   double min;
38
39   double max;
40
41   double mean;
42   
43   double stderr;
44
45   double var;
46
47   double stddev;
48 };
49
50
51
52 struct factor_statistics {
53
54   /* The value of the independent variable for this factor */
55   const union value *id;
56
57   /* An array of metrics indexed by dependent variable */
58   struct metrics *stats;
59
60 };
61
62
63
64 void metrics_precalc(struct metrics *fs);
65
66 void metrics_calc(struct metrics *fs, double x, double weight);
67
68 void metrics_postcalc(struct metrics *fs);
69
70
71
72
73 /* These functions are necessary for creating hashes */
74
75 int compare_indep_values(const struct factor_statistics *f1, 
76                      const struct factor_statistics *f2, 
77                      int width);
78
79 unsigned hash_indep_value(const struct factor_statistics *f, int width) ;
80
81 void  free_factor_stats(struct factor_statistics *f, int width );
82
83
84 #endif