projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
lexer: New function lex_ofs_representation().
[pspp]
/
src
/
language
/
stats
/
means-calc.c
diff --git
a/src/language/stats/means-calc.c
b/src/language/stats/means-calc.c
index 54b4e9cce52bddfe3dd556b178dd3a0abe6f62d4..6aabbf50cbad1b8448eb3de326b882f43ce2f02e 100644
(file)
--- a/
src/language/stats/means-calc.c
+++ b/
src/language/stats/means-calc.c
@@
-36,22
+36,26
@@
#define _(msgid) gettext (msgid)
#define N_(msgid) (msgid)
#define _(msgid) gettext (msgid)
#define N_(msgid) (msgid)
+/* A base struct for all statistics. */
struct statistic
{
};
struct statistic
{
};
+/* Statistics which accumulate a single value. */
struct statistic_simple
{
struct statistic parent;
double acc;
};
struct statistic_simple
{
struct statistic parent;
double acc;
};
+/* Statistics based on moments. */
struct statistic_moment
{
struct statistic parent;
struct moments1 *mom;
};
struct statistic_moment
{
struct statistic parent;
struct moments1 *mom;
};
+
static struct statistic *
default_create (struct pool *pool)
{
static struct statistic *
default_create (struct pool *pool)
{
@@
-77,6
+81,8
@@
default_destroy (struct statistic *stat)
moments1_destroy (pvd->mom);
}
moments1_destroy (pvd->mom);
}
+
+/* Simple statistics have nothing to destroy. */
static void
simple_destroy (struct statistic *stat UNUSED)
{
static void
simple_destroy (struct statistic *stat UNUSED)
{
@@
-85,7
+91,7
@@
simple_destroy (struct statistic *stat UNUSED)
\f
/* HARMONIC MEAN: The reciprocal of the sum of the reciprocals:
\f
/* HARMONIC MEAN: The reciprocal of the sum of the reciprocals:
- 1 / (
1/(x_0) + 1/(x_1) + ... + 1/(x_{n-1})
) */
+ 1 / (
1/(x_0) + 1/(x_1) + ... + 1/(x_{n-1})
) */
struct harmonic_mean
{
struct harmonic_mean
{
@@
-163,6
+169,10
@@
geometric_get (const struct statistic *pvd)
\f
\f
+/* The getters for moment based statistics simply calculate the
+ moment. The only exception is Std Dev. which needs to call
+ sqrt as well. */
+
static double
sum_get (const struct statistic *pvd)
{
static double
sum_get (const struct statistic *pvd)
{
@@
-211,9
+221,6
@@
stddev_get (const struct statistic *pvd)
return sqrt (variance_get (pvd));
}
return sqrt (variance_get (pvd));
}
-
-
\f
-
static double
skew_get (const struct statistic *pvd)
{
static double
skew_get (const struct statistic *pvd)
{
@@
-333,6
+340,8
@@
struct range
double max;
};
double max;
};
+/* Initially min and max are set to their most (inverted) extreme possible
+ values. */
static struct statistic *
range_create (struct pool *pool)
{
static struct statistic *
range_create (struct pool *pool)
{
@@
-344,6
+353,8
@@
range_create (struct pool *pool)
return (struct statistic *) r;
}
return (struct statistic *) r;
}
+/* On each update, set min and max to X or leave unchanged,
+ as appropriate. */
static void
range_update (struct statistic *pvd, double w UNUSED, double x)
{
static void
range_update (struct statistic *pvd, double w UNUSED, double x)
{
@@
-356,6
+367,7
@@
range_update (struct statistic *pvd, double w UNUSED, double x)
r->min = x;
}
r->min = x;
}
+/* Get the difference between min and max. */
static double
range_get (const struct statistic *pvd)
{
static double
range_get (const struct statistic *pvd)
{