[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: |
Sun, 02 Jul 2006 23:13:23 +0000 |
CVSROOT: /cvsroot/pspp
Module name: pspp
Changes by: Jason H Stover <jstover> 06/07/02 23:13:23
Modified files:
src/math/ts : ChangeLog innovations.c
Log message:
fixed subscript in sum; added new functions; fixed allocation of theta
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pspp/src/math/ts/ChangeLog?cvsroot=pspp&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/pspp/src/math/ts/innovations.c?cvsroot=pspp&r1=1.8&r2=1.9
Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/pspp/pspp/src/math/ts/ChangeLog,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- ChangeLog 1 Jul 2006 23:54:02 -0000 1.7
+++ ChangeLog 2 Jul 2006 23:13:23 -0000 1.8
@@ -1,3 +1,13 @@
+2006-07-02 Jason Stover <address@hidden>
+
+ * innovations.c (get_coef): Moved instructions to
+ innovations_update_coeff() and init_theta().
+ * innovations.c (get_coef): Fixed allocation of theta.
+ * innovations.c (innovations_update_theta): New function.
+ * innovations.c (init_theta): New function.
+ * innovations.c (innovations_convolve): Fixed upper bound of
+ subscript in sum.
+
2006-07-01 Jason Stover <address@hidden>
* innovations.c: Use gsl_matrices to avoid use of casefiles by
Index: innovations.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/math/ts/innovations.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- innovations.c 1 Jul 2006 23:54:02 -0000 1.8
+++ innovations.c 2 Jul 2006 23:13:23 -0000 1.9
@@ -104,7 +104,7 @@
{
y -= est[j]->mean;
*(est[j]->cov + lag) += y * x;
- est[i]->n_obs += 1.0;
+ est[j]->n_obs += 1.0;
}
}
}
@@ -126,9 +126,9 @@
int k;
double result = 0.0;
- for (k = 0; k < i; k++)
+ for (k = 0; k < j; k++)
{
- result += theta[i-1][i-k-1] * theta[j-1][j-k-1] * est->scale[k];
+ result += theta[i-1][i-k-1] * theta[j][j-k-1] * est->scale[k];
}
return result;
}
@@ -149,45 +149,60 @@
}
est->scale[i] = result;
}
-
static void
-get_coef (const gsl_matrix *data,
- struct innovations_estimate **est, size_t max_lag)
+init_theta (double **theta, size_t max_lag)
{
- 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]));
+ size_t j;
- }
- for (n = 0; n < data->size2; n++)
- {
for (i = 0; i < max_lag; i++)
{
- for (j = 0; j < i; j++)
+ for (j = 0; j <= i; j++)
{
theta[i][j] = 0.0;
}
}
- innovations_update_scale (est[n], theta[0], 0);
+}
+static void
+innovations_update_coeff (double **theta, struct innovations_estimate *est,
+ size_t max_lag)
+{
+ size_t i;
+ size_t j;
+ size_t k;
+ double v;
+
for (i = 0; i < max_lag; i++)
{
- v = est[n]->cov[i];
+ v = est->cov[i];
for (j = 0; j < i; j++)
{
k = i - j;
- theta[i-1][k-1] = est[n]->cov[k] -
- innovations_convolve (theta, est[n], i, j);
+ theta[i-1][k-1] = est->cov[k] -
+ innovations_convolve (theta, est, i, j);
+ }
+ innovations_update_scale (est, theta[i], i);
}
- innovations_update_scale (est[n], theta[i], i);
+}
+static void
+get_coef (const gsl_matrix *data,
+ struct innovations_estimate **est, size_t max_lag)
+{
+ size_t i;
+ size_t n;
+ 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 < data->size2; n++)
+ {
+ init_theta (theta, max_lag);
+ innovations_update_scale (est[n], theta[0], 0);
+ innovations_update_coeff (theta, est[n], max_lag);
/* Copy the final row of coefficients into EST->COEFF.*/
for (i = 0; i < max_lag; i++)
{
@@ -213,6 +228,7 @@
pspp_coeff_set_estimate (est[n]->coeff[i], theta[max_lag - 1][i]);
}
}
+
for (i = 0; i < max_lag; i++)
{
free (theta[i]);
- [Pspp-cvs] pspp/src/math/ts ChangeLog innovations.c,
Jason H Stover <=