help needed to make transition probability matrix
Afficher commentaires plus anciens
Dear all, I am brainstorming how to make transition probability matrix and had a code below. It does not work. It could be great to check my code and have a idea so that sum of all values in the matrix shall be one. My mind blocked after thinking a lot.
A = idxMA;
nmax = max(A);
nseries = numel(A);
states = zeros(nseries, nmax);
for i = 1:nmax
states(:,i) = A==i;
end
jumpprob = zeros(nmax);
jmps = 1:nmax;
for i = 1:nmax
X = jmps(i);
for j = 1:njumps
Y = jmps(j);
P = jumps(A, X, Y);
jumpprob(i,j) = P/nseries;
end
end
function [ P ] = jumps(data, X, Y )
%UNTITLED5 Summary of this function goes here
% Detailed explanation goes here
ndata = length(data);
nstates = 0;
for i = 1:ndata-1
if data(i) > X && data(i+1) <= Y
nstates = nstates + 1;
end
end
P = nstates;
end
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Mathematics dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!