[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pspp-cvs] pspp/src/math/ts ChangeLog innovations.c
From: |
Jason H Stover |
Subject: |
[Pspp-cvs] pspp/src/math/ts ChangeLog innovations.c |
Date: |
Wed, 21 Jun 2006 08:54:46 +0000 |
CVSROOT: /cvsroot/pspp
Module name: pspp
Changes by: Jason H Stover <jstover> 06/06/21 08:54:46
Modified files:
src/math/ts : ChangeLog innovations.c
Log message:
added scale update to innovations algorithm
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pspp/src/math/ts/ChangeLog?cvsroot=pspp&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/pspp/src/math/ts/innovations.c?cvsroot=pspp&r1=1.4&r2=1.5
Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/pspp/pspp/src/math/ts/ChangeLog,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- ChangeLog 16 Jun 2006 09:24:35 -0000 1.4
+++ ChangeLog 21 Jun 2006 08:54:46 -0000 1.5
@@ -1,3 +1,9 @@
+2006-06-21 Jason Stover <address@hidden>
+
+ * innovations.c (innovations_update_scale): New function.
+ * innovations.c (get_coef): Initialize and free the innovations
+ coefficients. Call innovations_update_scale ().
+
2006-06-16 Jason Stover <address@hidden>
* innovations.c (innovations_convolve): New function.
Index: innovations.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/math/ts/innovations.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- innovations.c 16 Jun 2006 09:18:34 -0000 1.4
+++ innovations.c 21 Jun 2006 08:54:46 -0000 1.5
@@ -179,34 +179,72 @@
for (k = 0; k < i; k++)
{
- result += theta[i][i-k] * theta[j][i-j] * est->cov[k];
+ result += theta[i-1][i-k-1] * theta[j-1][j-k-1] * est->scale[k];
}
return result;
}
static void
+innovations_update_scale (struct innovations_estimate *est, double *theta,
+ size_t i)
+{
+ double result = 0.0;
+ size_t j;
+ size_t k;
+
+
+ result = est->cov[0];
+ for (j = 0; j < i; j++)
+ {
+ k = i - j;
+ result -= theta[k] * theta[k] * est->scale[j];
+ }
+ est->scale[i] = result;
+}
+
+static void
get_coef (size_t n_vars, const struct casefile *cf,
struct innovations_estimate **est, size_t max_lag)
{
- int j;
- int i;
- int k;
+ size_t j;
+ size_t i;
+ size_t k;
size_t n;
double v;
double **theta;
+ theta = xnmalloc (max_lag, sizeof (*theta));
+ for (i = 0; i < max_lag; i++)
+ {
+ theta[i] = xnmalloc (i+1, sizeof (theta[i]));
+
+ }
for (n = 0; n < n_vars; n++)
{
for (i = 0; i < max_lag; i++)
{
+ for (j = 0; j < i; j++)
+ {
+ theta[i][j] = 0.0;
+ }
+ }
+ innovations_update_scale (est[n], theta[0], 0);
+ for (i = 0; i < max_lag; i++)
+ {
v = est[n]->cov[i];
for (j = 0; j < i; j++)
{
k = i - j;
- theta[i][k] = est[n]->cov[k] -
- innovations_convolve (theta, est, i, j);
+ theta[i-1][k-1] = est[n]->cov[k] -
+ innovations_convolve (theta, est[n], i, j);
}
+ innovations_update_scale (est[n], theta[i], i);
}
}
+ for (i = 0; i < max_lag; i++)
+ {
+ free (theta[i]);
+ }
+ free (theta);
}
struct innovations_estimate **
@@ -228,7 +266,8 @@
est[i]->variable = vars[i];
est[i]->mean = 0.0;
est[i]->variance = 0.0;
- est[i]->cov = xnmalloc (lag, sizeof (est[i]->cov));
+ 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));
for (j = 0; j < lag; j++)
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pspp-cvs] pspp/src/math/ts ChangeLog innovations.c,
Jason H Stover <=