[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pspp-cvs] pspp/src/math/ts ChangeLog innovations.c innova...
From: |
Jason H Stover |
Subject: |
[Pspp-cvs] pspp/src/math/ts ChangeLog innovations.c innova... |
Date: |
Mon, 03 Jul 2006 19:41:21 +0000 |
CVSROOT: /cvsroot/pspp
Module name: pspp
Changes by: Jason H Stover <jstover> 06/07/03 19:41:21
Modified files:
src/math/ts : ChangeLog innovations.c innovations.h
Log message:
subscript fixes; added free functions
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pspp/src/math/ts/ChangeLog?cvsroot=pspp&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/pspp/src/math/ts/innovations.c?cvsroot=pspp&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/pspp/src/math/ts/innovations.h?cvsroot=pspp&r1=1.3&r2=1.4
Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/pspp/pspp/src/math/ts/ChangeLog,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- ChangeLog 2 Jul 2006 23:13:23 -0000 1.8
+++ ChangeLog 3 Jul 2006 19:41:20 -0000 1.9
@@ -1,3 +1,11 @@
+2006-07-03 Jason Stover <address@hidden>
+
+ * innovations.c (init_theta): Fixed subscripts.
+ * innovations.c (innovations_update_coeff): Fixed subscripts.
+ * innovations.c (get_covarience): Fixed subscripts.
+ * innovations.c (pspp_innovations_free): New function.
+ * innovations.c (pspp_innovations_free_one): New function.
+
2006-07-02 Jason Stover <address@hidden>
* innovations.c (get_coef): Moved instructions to
Index: innovations.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/math/ts/innovations.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- innovations.c 2 Jul 2006 23:13:23 -0000 1.9
+++ innovations.c 3 Jul 2006 19:41:20 -0000 1.10
@@ -97,20 +97,20 @@
if (!gsl_isnan (x))
{
x -= est[j]->mean;
- for (lag = 1; lag <= max_lag && lag < data->size1 - max_lag;
lag++)
+ for (lag = 1; lag <= max_lag && lag < (data->size1 - i); lag++)
{
y = gsl_matrix_get (data, i + lag, j);
if (!gsl_isnan (y))
{
y -= est[j]->mean;
- *(est[j]->cov + lag) += y * x;
+ *(est[j]->cov + lag - 1) += y * x;
est[j]->n_obs += 1.0;
}
}
}
}
}
- for (lag = 0; lag <= max_lag && lag < data->size1 - max_lag; lag++)
+ for (lag = 1; lag <= max_lag; lag++)
{
for (j = 0; j < data->size2; j++)
{
@@ -141,10 +141,10 @@
size_t k;
- result = est->cov[0];
+ result = est->variance;
for (j = 0; j < i; j++)
{
- k = i - j;
+ k = i - j - 1;
result -= theta[k] * theta[k] * est->scale[j];
}
est->scale[i] = result;
@@ -174,14 +174,14 @@
for (i = 0; i < max_lag; i++)
{
- v = est->cov[i];
- for (j = 0; j < i; j++)
+ for (j = 0; j <= i; j++)
{
k = i - j;
- theta[i-1][k-1] = est->cov[k] -
- innovations_convolve (theta, est, i, j);
+ theta[i][k] = (est->cov[k] -
+ innovations_convolve (theta, est, i, j))
+ / est->scale[k];
}
- innovations_update_scale (est, theta[i], i);
+ innovations_update_scale (est, theta[i], i + 1);
}
}
static void
@@ -246,13 +246,16 @@
est = xnmalloc (data->size2, sizeof *est);
for (i = 0; i < data->size2; i++)
{
- est[i] = xmalloc (sizeof **est);
+ est[i] = xmalloc (sizeof *est[i]);
/* est[i]->variable = vars[i]; */
est[i]->mean = 0.0;
est[i]->variance = 0.0;
+ /* COV does not the variance (i.e., the lag 0 covariance). So COV[0]
+ holds the lag 1 covariance, COV[i] holds the lag i+1 covariance. */
est[i]->cov = xnmalloc (lag, sizeof (*est[i]->cov));
est[i]->scale = xnmalloc (lag, sizeof (*est[i]->scale));
est[i]->coeff = xnmalloc (lag, sizeof (*est[i]->coeff));
+ est[i]->max_lag = (double) lag;
for (j = 0; j < lag; j++)
{
est[i]->coeff[j] = xmalloc (sizeof (*(est[i]->coeff + j)));
@@ -265,3 +268,29 @@
return est;
}
+
+static void
+pspp_innovations_free_one (struct innovations_estimate *est)
+{
+ size_t i;
+
+ assert (est != NULL);
+ free (est->cov);
+ free (est->scale);
+ for (i = 0; i < (size_t) est->max_lag; i++)
+ {
+ pspp_coeff_free (est->coeff[i]);
+ }
+}
+
+void pspp_innovations_free (struct innovations_estimate **est, size_t n)
+{
+ size_t i;
+
+ assert (est != NULL);
+ for (i = 0; i < n; i++)
+ {
+ pspp_innovations_free_one (est[i]);
+ }
+ free (est);
+}
Index: innovations.h
===================================================================
RCS file: /cvsroot/pspp/pspp/src/math/ts/innovations.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- innovations.h 1 Jul 2006 23:54:02 -0000 1.3
+++ innovations.h 3 Jul 2006 19:41:20 -0000 1.4
@@ -42,4 +42,5 @@
coefficient **coeff;
};
struct innovations_estimate ** pspp_innovations (const gsl_matrix *, size_t);
+void pspp_innovations_free (struct innovations_estimate **, size_t);
#endif
- [Pspp-cvs] pspp/src/math/ts ChangeLog innovations.c innova...,
Jason H Stover <=