# How do I choose the polynomials for a stochastic filter? - Transfer functions + Extended Least Square

I'm buildning a Mimimum Variance Controller(MVC) but I having som trouble to select the stochastic filter.

First of all! To build a MVC, you need a ARMAX model, in other words polynomial who look like this:

$$Ay = Bu + Ce$$

Where $y$ is the output, $u$ is the input and $e$ is the disturbance.

To create the MVC control law, we need to use this formula:

$$z^{d_0 -1}C = AF + G$$

Where

$$F = z^{d_0-1} + f_1 z^{d_0 -2} + ... + f_{d_0 - 1}$$ $$A = z^{n} + a_0 z^{n-1} + ... + a_{n - 1}$$ $$B = z^{m} + b_0 z^{m-1} + ... + b_{m - 1}$$ $$G = g_0z^{n-1} + g_1 z^{n -2} + ... + g_{n - 1}$$

And

$$n = deg(C) = deg(A)$$ $$m = deg(B)$$ $$d_0 = n - m$$

Normaly, if $n = deg(A) = deg(C) = 2$ and $m = deg(B) = 1$, which is the most standard case, then we have the control law:

$$y = - \frac{(c_0 - a_0)z + (c_1 - a_1)}{b_0z + b_1}$$

I also using Extended Least Square algorithm:

$$P^{-1}(t) = P^{-1}(t-1) + \phi(t-1)\phi ^T(t-1)$$ $$\hat \theta(t) = \hat \theta(t-1) + P(t)(y(t) - \phi(t-1) ^T \theta)$$

To estimate the parameters in $A, B, C$ polynomials.

It works great if I do open loop, with with cloed loop, it looks very bad.

Right now I using a ARMAX model:

$$(z^2 -1.9507754z + 0.9704455)y = (0.0049421z + 0.0048929)u + (z^2 + 0.003z + 0.001)e$$

And the control law:

$$y = -\frac{1.9537754z + -0.9694455}{0.0049421z + 0.0048929}$$

With the open loop simulation, I get the parameters $\theta$ like this. Those are perfect estimated!

The output looks like this:

But if I do closed loop. The $\theta$ looks like this:

But the output looks perfect!

My goal here is to select a filter on the input and output, who goes right into the ELS estimator.

Question:

Do you know what kind of filter I should use so I can get better estimation?