Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy variable do not change?
    primarykey
    data
    text
    <p>I have following code *. I this I change variable "epsf1" by previous value"epsf1 = eps[ii,1]-c1*epsf1". I print its value and it is 0. But it should be something completelly different. I can not find why it is happening and I am not able to make shorter code with same problem. It looks like value from "eps[ii]" is not used in "epsf1 = eps[ii,1]-c1*epsf1;" statement.</p> <p>*:</p> <pre><code>delka_experimentu = 1000; lambda = 1; Q = diag(3); e = rnorm(delka_experimentu); u = rnorm(delka_experimentu);#rep(10,delka_experimentu) y = rep(0,delka_experimentu); y[1] = e[1]; for(ii in c(2:delka_experimentu)){ y[ii] = 0.5*y[ii-1]+0.3*u[ii-1]+e[ii]-0.2*e[ii]; } Res = matrix(0,delka_experimentu,6); P = 1000*diag(3); R1 = 0.1*diag(3); K = matrix(0,3,1); eps = matrix(0,delka_experimentu,1) epsf1 = y[1]; print(c(epsf1)) epsf2 = 0; ef3 = 0; yf1 = y[1]; yf2 = 0; yf3 = 0; uf1 = u[1]; uf2 = 0; uf3 = 0; eps[1,1] = y[1]; epst1 = 0; pomocna1 = 0; pomocna2 = 0; theta = matrix(0,3,1); for(ii in 2:30){ #delka_experimentu a1 = theta[1]; b1 = theta[2]; c1 = theta[3]; pomocna1 = epsf1; epsf1 = eps[ii,1]-c1*epsf1; epsf2 = pomocna1; print(c(epsf1)) pomocna1 = yf1; yf1 = y[ii]-c1*yf1; yf2 = pomocna1; pomocna1 = uf1; uf1 = u[ii]-c1*uf1; uf2 = pomocna1; eps[ii,1] = y[ii]+a1*y[ii-1]-b1*u[ii-1]-c1*eps[ii-1] #if(eps[ii]*eps[ii]&gt;100){paste("problem",ii)} psi = matrix(c(yf2,uf2,epsf2),3,1); b = t(psi)%*%P%*%psi; P = (P - P%*%psi%*%solve(1+b[1,1])%*%t(psi)%*%P)/lambda #lambda*solve(Q) K = P%*%psi%*%solve(1+b[1,1]); #lambda*solve(Q) theta = theta + K%*%eps[ii]; Res[ii,] = theta; } plot(c(0,delka_experimentu),c(min(Res,-0.5),max(Res,1)),col="white") lines(Res[,1],col="red") #lines(Res[,2],col="red",type=o) lines(Res[,3],col="blue") #lines(Res[,4],col="blue") lines(Res[,5]) #lines(Res[,6]) lines(c(0,delka_experimentu),c(-0.5,-0.5),col="red") lines(c(0,delka_experimentu),c(0.3,0.3),col="blue") lines(c(0,delka_experimentu),c(-0.2,-0.2)) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload