Effacer les filtres
Effacer les filtres

Why is my while loop not working?

2 vues (au cours des 30 derniers jours)
Leo Tu
Leo Tu le 7 Juil 2021
Commenté : KSSV le 14 Juil 2021
From this code, I am looking to get the nll values for all s = 0:999 where s is a parameter. When I run it, it runs very slow and only gives out one value of nll. Can anyone help me with getting the nll values for all values of the parameter s from 0 to 999.
% Initial parameter values
s = 0;
mu = 0.1;
om = 0.01;
% AT is a row vector
while s<=999
for t = s+1:length(AT)
k = abs(s:-1:(s-t+1));
id = [(t-1):-1:0]+1;
lambda(t) = mu+sum(om.^k.*AT(id))/sum(om.^k);
j = 1:length(lambda);
nll = -sum(j.*log(lambda(j)))+sum(lambda(j));
end
s = s+1;
end
  5 commentaires
David Hill
David Hill le 13 Juil 2021
Better describe the equation of lambda with respect to s and your constants.
KSSV
KSSV le 14 Juil 2021
One reason for slow is you have not initiated lambda.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by