How to solve exponential function in iterations for large matrix (varying values)

5 views (last 30 days)
Hi,
I am just a beginner in MATLAB but keen to learn more for my studies.
I am trying to solve an equation for large matrix (rectangular) of M x N dimension in loop for n number of iterations. My equation is
here, p(t) is the probability vector, A is the M x N dimension matrix, p(0) is the initial probability. I want to fetch max value in descending order from each column from the given matrix in every iteration and solve the equation and store all the p(t) values in separate matrix and then plot the graph of change in probability. You can assume the dimension of matrix as 30000 x 4500.
The loop should run until the sum of column probabilities is equal to 1 or close to 1. Main aim is to select only those values from the column from given matrix which can give max value of p(t) and once the sum is close to 1.. say 0.984 then it should stop selecting the values.
I've tried to write code and solve this equation in loop by taking all the values from A one by one but i am getting funny outputs like 44.24, 7.98..and so on in the matrix, which is not possible because sum of probabilities are never greater than 1. These values 44.24, 7.98.. are single value of indexes in the output matrix of p and if i do the sum of column then it goes like 90, 40... etc which is wrong as per law of conservation.
Can someone guide me how to do this? and achieve the task of: Selecting max values from A matrix columns in decreasing order and solve this equation in loop and store in output matrix of p(t) whose column sum should be less than or equal to 1. It should keep on taking values from the matrix A until the sum reaches 1 or close to one and loop should stop and plot the graph. Suppose, in a matrix of [100x400] we have 100 values in column and we have 40 different columns and we started solving the equation in loop to calculate the probability.. we start with selecting max value from each column and store the output in different matrix..and side by side output matrix column should be monitored.... if we have already taken 60 values from each column (we have 40 columns in this case) from matrix A to solve the equation and our resulting matrix each column sum is 1 or close to 1 then we will stop solving the equation and stop the loop and plot the graph of resulting matrix. Ignoring other values in the matrix is like truncating state-space. If you think you have some idea how to truncate the values from the matrix, i will be thrilled to adopt it in my implementation. Basically, matrix contains the state-space value of reactions.
If matrix is very large it can be partitioned like
and then all the submatrix A1, A2, A3... are used to solve the equation at the same time parallely (it will decrease the computational time) and result will be stored in one output matrix of p(t) (state transition probability matrix).
Please see what i have tried to do (I know it is not correct):
p0=0.01;
t=[0 20];
p(1) = p0; % Initial condition gives solution at t=0
for (i=1:(length(t)-1))
dpdt = (exp(A)) * p(i)
end
plot (t,p);
legend ('Approximate');
I am using the code given below to partition the matrix separately and then calling it in the above code to do further calculations. I want everything in single code so that in one run i can execute all the functions/commands/code and get the answer as a plot and matrix.
DimMat = size(Y);
Indexs = floor(DimMat / 2);
V11 = Y(1:Indexs(1),1:Indexs(2));
V12 = Y(1:Indexs(1),(Indexs(2)+1):end);
V21 = Y((Indexs(1)+1):end,1:Indexs(2));
V22 = Y((Indexs(1)+1):end,(Indexs(2)+1):end);
I have invested so much time in figuring out how to do this but i am not getting how to move ahead and feeling frustrated because i am not getting any success. I would be very happy if i get some expert advice on this.
  7 Comments
RK
RK on 28 Aug 2017
Thanks Robert. I am not sure why I am getting rectangular matrix, so at present I can't use expm to solve it. I want to understand where I am doing wrong. If I have to get markov transition probability matrix A which contains the state space of a network of following reactions, then how shall I get it?
The rate constants are k1 = 4, k2 = 5 and k3 = 1. The initial species counts are 50 copies of S, 20 copies of E1, and 10 copies of E2. The other species counts are initially zero.
Walter Roberson
Walter Roberson on 28 Aug 2017
There has to be a probability of each state transitioning to each other possible state; that gives you a square matrix. If the structure is such that some of the transitions are not possible, then the associated probability is 0.

Sign in to comment.

Answers (0)

Categories

Find more on Mathematics 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!