HI.Can someone please help me to create a transition probability matrix for the given data using markov chain?
조회 수: 1 (최근 30일)
이전 댓글 표시
I have data for time,acceleration,speed.I'm attaching the data file above.I'm trying to generate a 2 dimensional transition probability matrix of velocity and acceleration but with different state of velocity and acceleration. The idea is generate a particular speed and acceleration I would like to know the next most probable speed and acceleration.I tried to use a code ,my i could not succeed if someone help me on this it will be a great help.Thank you.
binN='bindata.mat';
%%First bin data into categories
speedBinN = 5;
aceelBinN = 5;
speed = histc( binN(:,2), linspace(min(binN(:,2)),max(binN(:,2)),speedBinN) ); % bin them into categories
accel = histc( binN(:,3), linspace(min(binN(:,3)),max(binN(:,3)),aceelBinN) );
%%count up transitions
transCountMat = zeros(speedBinN,aceelBinN,speedBinN,aceelBinN);
for n = 1:size(binN,1)-1
transCountMat( speed(n),accel(n),speed(n+1),accel(n+1) ) = transCountMat( speed(n),accel(n),speed(n+1),accel(n+1) ) + 1;
end
%%calculate probabilities
%trans = full(sparse(bins(1:end-1), bins(2:end), 1));
%trans = bsxfun(@rdivide, trans, sum(trans,2));
sumOver = sum( sum(transCountMat, 4), 3);
transMat = bsxfun( @rdivide, transCountMat, sum(sumOver,2) )
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!