Why Power of Matrix with decimal values gives really big numbers?
6 views (last 30 days)
Show older comments
Alexandra Carvalho
on 7 Jan 2020
Edited: Christine Tobler
on 13 Jan 2020
Hello!
I've generated a matrix with decimal values using
T = rand(20);
And it looks like this:
However,
When I do
T^20
The answer I get is a matrix with really big numbers such as the following.
How come multiplications of decimal values give such great numbers? Is this correct? Is the command not doing what I think it is?
Thanks in advance,
2 Comments
Stephen23
on 7 Jan 2020
Edited: Stephen23
on 7 Jan 2020
"How come multiplications of decimal values give such great numbers?"
Because matrix power is defined as repeated matrix multiplication, and as any high-school student will tell you, that involves lots of summing as well as multiplication.
"Is this correct?"
Yes.
"Is the command not doing what I think it is? "
Possibly, but as you did not explain what you expect to happen, we don't know what the problem is. Possibly you did not pay attention to the differences between matrix operations (what you used) and array operations:
In order to use MATLAB you need to know the difference.
Accepted Answer
John D'Errico
on 7 Jan 2020
Edited: John D'Errico
on 7 Jan 2020
This is basic linear algebra. I think you do not understand what is happening, or perhaps you do not understand Markov transition matrices. Something along those lines. For example...
R = rand(20);
eig(R)
ans =
9.8584 + 0i
0.3537 + 1.1913i
0.3537 - 1.1913i
-1.1665 + 0.26994i
-1.1665 - 0.26994i
-0.71294 + 0.74919i
-0.71294 - 0.74919i
-0.80233 + 0.054562i
-0.80233 - 0.054562i
-0.10344 + 0.80806i
-0.10344 - 0.80806i
0.8188 + 0.37927i
0.8188 - 0.37927i
0.69076 + 0i
0.62369 + 0i
0.40071 + 0.42737i
0.40071 - 0.42737i
-0.34121 + 0i
0.034137 + 0.41554i
0.034137 - 0.41554i
As it turns out, there is one direction that corresponds to a large eigenvalue. So when we raise R to high powers, we see R^20, for example, has huge numbers.
max(R^20,[],'all')
ans =
5.9807e+18
But is R a markov transition matrix? NO!!!!!!!! Just because R has no numbers in it that are larger than 1, does NOT mean it has the properties of a transition matrix. One such important property is that the rows of R must all sum to 1. Does that happen?
sum(R,2)
ans =
10.91
8.8577
9.8103
10.163
8.504
9.3237
11.721
11.131
8.2243
8.5949
12.257
8.3164
10.589
11.276
9.1634
9.3135
9.8294
9.5156
10.034
9.174
Now see what happens...
T = R./sum(R,2); % row sums will now be 1.
max(T^20,[],'all')
ans =
0.068219
If you just raise some random matrix to large powers, then you should expect to get garbage results.
Remember that the rows of a Markov transition matrix represent probabilities of a transition to a given state. What do we know about probabilities? They must sum to 1.
More Answers (3)
Star Strider
on 7 Jan 2020
It depends what you want to do. Note that ‘T^20’ multiplies the entire matrix by itself 20 times (although the actual algorithm uses the Cayley-Hamilton theorem to do the calculation).
Run this for an illustration:
T = rand(20);
Tn = T;
for k = 1:5
Tn = Tn * T;
k
D = Tn(1:5, 1:5)
end
If you want to raise the elements of ‘T’ each to the 20th power, use the dot operator to specify element-wise operations:
T20 = T.^20
That will give an entirely different result.
3 Comments
Star Strider
on 7 Jan 2020
You never mentioned that you are calculateing Markov chain probabilities in your original post.
Christine Tobler
on 8 Jan 2020
Edited: Christine Tobler
on 13 Jan 2020
For a Markov Chain, you need the sum of each row to be 1 (as this represents the probability to transition to any state), and every element of the matrix to be within 0 and 1. With the general random matrix you are using, that is not the case.
Try the following matrix:
A = rand(10);
A = A./sum(A, 2);
You can verify that sum(A, 2) is now all 1, and the same is true for sum(A^20, 2).
2 Comments
David Goodmanson
on 8 Jan 2020
Hi Christine,
looks like your statement that the sum of each column equals one is not conistent with sum(A,2).
See Also
Categories
Find more on Descriptive Statistics 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!