problem with a for cycle

I have to iterate a recursive system of difference equation where in the matrix of coefficient the diagonal depends on the previous time vector. The code run if into the for cylce i use mu_0 (the initial vector) but i'm not able to make use of the mu_(t-1) vector (the vector of the previous period).
Here the code. If I didn't explain well let me know
% initialize vector
mu_0 = rand([n, 1]);
% matrice di adiacenza
A = rand(n, n);
% normalizzo la matrice
A= diag(1./sum(A,2))*A;
% definisco la diagonale
da=diag(diag(A));
% separo la matrice dalla diagonale, A1 è il netowrk senza pesi
% individuali
A1=A-diag(diag(A));
for t=1:100
% bayesian updating:
% likelihood
p_t=1/2+ rand(n, 1)/4;
p1_t=diag(p_t);
%%PROBLEM
mu_t=mu_t-1;
m_t=p1_t*mu_t+(1-p1_t)*(1-mu_t) ;
% eta è l'updating bayesiano senza il prior (mu)
eta_t=p_t./m_t;
da1=da*eta_t;
mu_t = (A1^t+diag(da1))*mu_t-1;
%or mu_t = (A1^t+diag(da1))^0*mu_t;
end

Risposte (0)

Categorie

Scopri di più su Mathematics and Optimization in Centro assistenza e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by