Hi ...how to generate transition probability matrix using markov property for acceleration and velocity ?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I want to generate a transition probability matrix for acceleration and velocity ,but the problem is I don't have data for acceleration and velocity so I want to use rand command to generate a random values.I already found a code for acceleration and velocity data but in this code they have loaded a data and from that data they generate the TPM matrix .But in my case I want to use a rand command for accel and velocity in order build the TPM matrix .How can I do it?Thank you.
function transMat = mwExample
load('Sample data set mathworks.mat')
%%First bin data into categories
speedBinN = 5;
aceelBinN = 5;
speed = binit( data(:,2), linspace(min(data(:,2)),max(data(:,2)),speedBinN) ); % bin them into categories
accel = binit( data(:,3), linspace(min(data(:,3)),max(data(:,3)),aceelBinN) );
%%count up transitions
transCountMat = zeros(speedBinN,aceelBinN,speedBinN,aceelBinN);
for ii = 1:size(data,1)-1
transCountMat( speed(ii),accel(ii),speed(ii+1),accel(ii+1) ) = transCountMat( speed(ii),accel(ii),speed(ii+1),accel(ii+1) ) + 1;
end
%%calculate probabilities
sumOverPossibleDestinations = sum( sum(transCountMat, 4), 3);
transMat = bsxfun( @rdivide, transCountMat, sumOverPossibleDestinations )
0 Kommentare
Antworten (1)
Sarah Mohamed
am 3 Jan. 2018
Assuming 'data' contains the speed and acceleration loaded from the sample file, you can build a matrix of uniformly distributed random numbers using the 'rand' function.
It looks like 'data' is just a 2D matrix. If column 2 of 'data' contains the speed and column 3 contains the acceleration, you could create a random 2D matrix with three columns via:
data = rand(100, 3);
For more on this function, you may refer to the documentation link below:
2 Kommentare
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!