1

Currently I am developing an online algorithm for harmonic tidal prediction. The measurements collected are $(y_i , t_i)$, with $y_i$ the height of the water (in meter) and $t_i$ the time of measurement (in hours). As the tide is (assumed to be) a result of $d$ harmonic effects, it can be modelled as

$$ y \approx \sum_{j=1} ^{d} w^j \cos(H_j t ) + \sum_{j = 1} ^{d} w^{d+j} \sin(H_j t) $$ Where $(H_1 \cdots H_d)$ are constants corresponding with the harmonic effects, and $(w^1 \cdots w^{2d} )$ the weights to be determined. If we define $x_i$ as $$x_i = \begin{pmatrix} \cos(H_1 t_i)\\ \vdots \\ \cos(H_d t_i) \\ \sin(H_1 t_i) \\ \vdots \\ \sin(H_d t_i) \end{pmatrix} $$

On this transformed data $(y_i, x_i)$ I employ a recursive least squares algorithm, characterised by the following formulae: $$ \Gamma_i = \Gamma_{i-1} - \dfrac{\Gamma_{i-1}x_i x_i ^T \Gamma_{i-1}}{1+ x_i ^T\Gamma_{i-1} x_i} \\ w_i = w_{i-1} - \Gamma_{i}x_i (x_i ^T w_{i-1} -y_i) $$ Where $w_0 = 0 \in \mathbb{R}^{2d}$ and $\Gamma_0 = 0 \in \mathbb{R}^{2d \times 2d}$.

I have the algorithm working for $d \leq 5$, yet at a try for $d = 37$, a flaw has appeared.

The predictions get off to a wrong start, predicting high when low water and vice versa. As the algorithm's correction of $w_i$ is proportionate to the prediction error (due to the last factor in the definition of $w_i$), it starts to overcompensate, resulting in an even bigger error in the next step. Then this big error induces another big overcompensation in the next step, etc. etc...

A little illustration is shown below, illustrating the abnormal growth in predictions between steps 1, 2 and 3.

enter image description here

My question is if someone has any thought on what the cause might be and ,if possible, what could be a solution to this.

PS: I realize this is a very specific question, yet I hope I have given sufficient information on the problem without stretching this post any further. If not, please comment.

Mathijs
  • 21
  • Two ideas: (1) your program is numerically unstable, and small errors in the calculation are being magnified. Figuring out how to perform a calculation in a numerically stable fashion is sometimes very tricky. For $d\le 5$, these errors don't get a chance to grow enough to overcome the convergence of the algorithm, but for $d = 37$, they are out-of-control before the convergence can get strong enough to overcome them. (2) there is a "harmonic effect" you've missed which doesn't match any harmonic of the $H_i$ you've picked. Your algorithm can't converge because of it. – Paul Sinclair Aug 07 '19 at 23:08
  • As for solutions, the second is easier: do a fast fourier transform on your data, and see if it shows any spikes about harmonics not in your list. For the first, check to see if you get any really, really big or small intermediate values (for any variable at any point of the calculation). These are highly indicative of an unstable algorithm. – Paul Sinclair Aug 07 '19 at 23:14
  • The intermediate values do not appear out of line in comparison to earlier results, and the set of $37$ harmonics I am currently using is already way more extensive than the 'usual' set of only $18$, so I shouldn't be missing any significant harmonic effect. I am currently exploring an option of running ordinary least squares on the first $i$ observations to obtain a decent model, and then meliorate said model through recursive least squares, to prevent these grave errors from arising. – Mathijs Aug 08 '19 at 07:15

0 Answers0