You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
How to get πx (steady-state probabilities of x?in order to plot these equations in MATLAB?
2 views (last 30 days)
Show older comments
Sir,
I want to plot these attached equations using MATLAB. For plotting these equations, there are three variables. Out of which, I have values of two variables with me. So, I am looking for the value of the third variable 'πx'. How to get the values of πx (also called steady state probability of x). I have attached the screenshot of equations. Actually, if I get the values of πx, I would easily be able to plot the equations in MATLAB. I am unable to get the steady-state probabilities of x.
Please help
I have also attached the values of x along with these equations.
Regards
Surabhi
Whatever, the case is either simulation or plotting. I am confused on how to solve to get steady-state probabilities and hence plot the equations.
11 Comments
Rik
on 15 Oct 2017
surabhi sachdeva
on 18 Oct 2017
Sir, the authors have written using MATLAB program they have found out the steady-state probability and then plotted the equations in MATLAB.
Jan
on 18 Oct 2017
Edited: Jan
on 18 Oct 2017
@surabhi sachdeva: What exactly is your question? Which are "these" equations? You did not post the complete definition, but only a screen shot of two equations. But even if you post the full PDF, you cannot expect the readers of a forum to do your work. Please post, what you have tried so far and ask a specific question concerning Matlab.
Please do this by editing the question, not by adding a comment or pseudo-answer. Thanks.
If you consider the two links provided by Rik, your chances to get an answer will grow.
Walter Roberson
on 18 Oct 2017
What would you expect the plot to look like? You have a 729 by 729 numeric array: are you looking to create a 729 x 729 image with the locations color-coded by numeric value? Are you looking to create a 729 x 729 surface with the z being the numeric value?
surabhi sachdeva
on 18 Oct 2017
Sir,
I want to plot these attached equations using MATLAB. For plotting these equations, there are three variables. Out of which, I have values of two variables with me. So, I am looking for the value of the third variable 'πx'. How to get the values of πx (also called steady state probability of x). I have attached the screenshot of equations and the plot.
Walter Roberson
on 18 Oct 2017
Edited: Walter Roberson
on 18 Oct 2017
I already directed you to the steady-state formulas at https://www.mathworks.com/matlabcentral/answers/359900-how-to-calculate-steady-state-probability#answer_284483 . Use them to calculate your πx values and then you should be able to go on to the calculations to plot.
surabhi sachdeva
on 18 Oct 2017
Edited: Walter Roberson
on 18 Oct 2017
Sir, I am unable to understand how the transition matrix got defined in he link suggested by you?
how do I have to define the transition matrix?
How have they been marked the values as attached?
Could you suggest something for my 36X36 matrix?
I mean to ask do I have to individually check each of my rows and the column for the values?
How to apply the rules? How to get such values in the transition matrix?
Walter Roberson
on 18 Oct 2017
You would create a matrix of the initial transition probabilities, and you would manipulate it in the way shown in order to arrive at the steady-state probabilities.
The transition matrix would be the usual: entry (J,K) says "Given that you are already in state J, what is the probability of transitioning to state K?". If you have algorithms that allow you to fill out that initial table, then you should use the algorithms.
surabhi sachdeva
on 19 Oct 2017
Edited: surabhi sachdeva
on 19 Oct 2017
Sir, I have state transition rules available to me, which I am not able to understand how to apply to the states(J, K)
Could you please give me a hint on how to apply this kind of rules to (J, K)
I have attached rules, kindly suggest something regarding how these rules to be applied.
Here (i,j,k,l,m,n) represents a state (J,K)
Each state is represented by (i,j,k,l,m,n) e.g. 101101, 101110,..... and many more.
As, if we say for all i<Np and there is a transition from (i,j,k,l,m,n) to (i+1, j, k,l,m,n) then it should be displayed 'λp'. How is this possible?
What code is to be written in MATLAB that automatically checks for the same type of transitions?
Kindly suggest
Accepted Answer
Walter Roberson
on 19 Oct 2017
Constructing the state tables is easy if you use the 12D array that I said you should use. I already showed you how it could be done; it is frustrating that you did not carry through.
Np = 2; %last state number for each entry, states are numbered from 0 to Np
%fill in the appropriate values for these probabilities. rand() is used to have _some_ value
lam_p = rand(); %lambda subscript p
gam_p = rand(); %gamma subscript p
gam_f = rand(); %gamma subscript f
%start building the table
Index = @(state_number) 1+state_number; %helper to allow us to use state numbers instead of indices
Ns = Index(Np); %number of states
TT = zeros( Ns * ones(1, 12) ); %transition table
case1_src_i = 0:Np-1;
TT(Index(case1_src_i), :, :, :, :, :, Index(case1_src_i+1), :, :, :, :, :) = lam_p;
case2_src_i = 1:Np;
case2_src_j = 0:Np-1;
case2_src_k = 1:Np;
TT(Index(case2_src_i), Index(case2_src_j), Index(case2_src_k), :, :, :, Index(case2_src_i-1), Index(case2_src_j+1), Index(case2_src_k-1), :, :, :) = gam_p;
case3_src_n = 0:Np-1;
case3a_src_j = 1:Np;
case3b_src_k = 1:Np;
case3c_src_l = 1:Np;
TT(:, Index(case3a_src_j), :, :, :, Index(case3_src_n), :, Index(case3a_src_j-1), :, :, :, Index(case3_src_n+1)) = gam_f;
TT(:, :, Index(case3b_src_k), :, :, Index(case3_src_n), :, :, Index(case3b_src_k-1), :, :, Index(case3_src_n+1)) = gam_f;
TT(:, :, :, Index(case3c_src_l), :, Index(case3_src_n), :, :, :, Index(case3c_src_l-1), :, Index(case3_src_n+1)) = gam_f;
T2 = reshape(TT, Ns^6, Ns^6); %2D transition table
Here, T2 is the 729 x 729 array that you are expecting -- the one that you would proceed to use the numeric steady-state calculations on.
23 Comments
surabhi sachdeva
on 19 Oct 2017
Sorry, sir for the frustration I gave.
And thank you so much for your help.
I will try it right now as said by you
Regards
Surabhi
surabhi sachdeva
on 27 Oct 2017
Sir, Why have you used 12-D array? Can you please specify the reason?
surabhi sachdeva
on 27 Oct 2017
Edited: surabhi sachdeva
on 27 Oct 2017
and sir,
I tried all the possible ways but I am not getting the results as expected
not able to get the values of steady-state probabilities.
Please help me out.
Regards
Surabhi
Walter Roberson
on 27 Oct 2017
Your rules are written in terms of (for example)
(i,j,k,l,m,n) to (i+1, j, k,l,m,n)
You have a source which is 6 dimensions long, and a destination that is 6 dimensions long, for a total of 12 dimensions. You can handle all of the (i,j,k,l,m,n) sources at once by using
(1:end-1,:,:,:,:,:)
in your source portion, and
(2:end,:,:,:,:,:)
as your destination
If you do not do this, if you encode the (i,j,k,l,m,n) into base 3 numbers from 0 to 728, then you need to figure out the decimal difference in indices between source and destination 6-tuples. For Case 1 and Case 2 that can be done as constants (same numeric difference for each situation within those two cases), but for the Case 3 situation, the difference in base 3 numbers pretty much needs to be calculated for each individual source because the numeric relationships between source and destination decimal representation are icky.
Using a 12-D representation makes the work easy and clear, and it is simple and fast to switch back to 2-D representation for final presentation.
surabhi sachdeva
on 27 Oct 2017
Edited: Walter Roberson
on 27 Oct 2017
Now, I am trying to code the leftover 3 cases(rules) given
case4_src_n = 1:Np-1;
case4a_src_i = 0;
case4b_src_i = 1:Np;
TT(:, Index(case4a_src_i), :, :, :, Index(case4_src_n), :, Index(case4a_src_k+1), :, :, :, Index(case4a_src_n-1)) = gam_r;
TT(:, :, Index(case4b_src_i), :, :, Index(case4_src_n), :, :, Index(case4b_src_i-1), :, :, Index(case4b_src_j+1)), Index(case4b_src_n-1) = gam_r;
Why is there an error Undefined function or variable 'case4a_src_k'.
I have to code the other 3 rules as well.
Walter Roberson
on 27 Oct 2017
You wrote,
TT(:, Index(case4a_src_i), :, :, :, Index(case4_src_n), :, Index(case4a_src_k+1), :, :, :, Index(case4a_src_n-1)) = gam_r;
Notice this includes Index(case4a_src_k+1) but you did not define case4a_src_k .
I recommend that you re-examine the line, marking each field
i j k l m n I
TT(:, Index(case4a_src_i), :, :, :, Index(case4_src_n), :,
J K L M N
Index(case4a_src_k+1), :, :, :, Index(case4a_src_n-1))
Your variable names disagree with the slot they correspond to.
surabhi sachdeva
on 27 Oct 2017
Thanks, sir,
I will get back to you after coding all the rules in the way you taught me to do.
Thanks again.
Regards
Surabhi
surabhi sachdeva
on 28 Oct 2017
Sir
Please see once
I have got this table.
I wanted to know how can I change the values of the input rows and columns from 1,2,3,4,........... to 100001,110011,...........?
Are these values in the file states is the initial input of the matrix?
I want the entities of the file states as an input for the matrix, How can it be done?
Kindly suggest
Regards Surabhi
Walter Roberson
on 28 Oct 2017
I do not know where that "states" matrix came from, or why it has duplicates. If for some reason you need to convert those to 2D index numbers, then
base2dec(states, 3) + 1
surabhi sachdeva
on 30 Oct 2017
Sir, this doesn't work out. I am not getting the steady-state probabilities as expected. What can I do? I am feeling helpless, not able to draw the graphs.
Please help.
Walter Roberson
on 30 Oct 2017
Could you remind me of the full set of rules? I think I've only seen 6 of them including the three case 3s.
Also please post your current code.
surabhi sachdeva
on 31 Oct 2017
Edited: surabhi sachdeva
on 31 Oct 2017
Sir, I want to tell you the complete scenario starting from the first.
Actually, I have been given a state-transition matrix Q having only 7 states as input. And it was mentioned it's just a part of state space and transition rates. Also, there are rules defined about these transitions.
I thought to generate the complete state space first. For which I used the MATLAB code and got 729 states with me.
Now, in order to generate the complete state transition matrix, I have to apply the transition rules to these 729 states I got. As from this state transition matrix only I will get the steady-state probabilities so as to plot the equations.
Firstly, sir I am confused do I have to generate the complete transition matrix for 729 elements or I have to use the Q (having 7 states) given to me? Can you help me regarding this?
Secondly, * If I have to generate the complete state transition matrix, please help me generating it for the entire 729 states.*
I have attached the sets of rules and the state space I got. I have also attached the state transition matrix which is given to me and I am expecting the same kind of transition rate matrix for the 729 elements.
Regards
Surabhi
Request you to also please suggest whether my idea of generating state space is right or do I have to use only the state space of 7 elements given to me?
Walter Roberson
on 31 Oct 2017
You need to use the full 729 states.
You did not post your current code.
surabhi sachdeva
on 31 Oct 2017
Currently, by using the code suggested by you, I made the code for 5 out of 6 cases given which I have attached.
I don't know whether I am going the right way or not? Please help.
I am expecting a 729 X729 matrix representation to be of the same kind as that of state space file I m uploading.
Please help me generating a 729X729 state transition matrix sir.
I would be very thankful.
Regards
Surabhi
surabhi sachdeva
on 31 Oct 2017
I am so sorry, sir
Please continue
Whenever you get free kindly respond
Regards
Surabhi
surabhi sachdeva
on 1 Nov 2017
Sir,
Kindly help me in the coding. I have attached the code file as well.
I want to use all the 729 states generated in the form of state transition matrix file I uploaded before as well.
Please help in writing the code for the same.
Regards
Surabhi
surabhi sachdeva
on 1 Nov 2017
Sir,
I need your help. Request you to kindly help me out solving the problem.
Regards
Surabhi
surabhi sachdeva
on 4 Nov 2017
@Walter Roberson sir,
You have not responded. Request you to please help me.
Regards
Surabhi
More Answers (0)
See Also
Categories
Find more on Function Creation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)