help needed to make transition probability matrix
이전 댓글 표시
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
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Mathematics에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!