[R] matrix exponential: M^0

Duncan Murdoch dmurdoch at pair.com
Tue Jan 20 17:37:14 CET 2004


On 20 Jan 2004 16:40:07 +0000, Federico Calboli <f.calboli at ucl.ac.uk>
wrote :

>Dear All, 
>
>I would like to ask why the zeroeth power of a matrix gives me a matrix
>of ones rather than the identity matrix:

R doesn't have a power operator that knows it's working on a matrix.
M^x raises each entry of M to the power x, it doesn't raise the matrix
to that power.  E.g.

> x
     [,1] [,2]
[1,]    2    2
[2,]    2    2
> x^2
     [,1] [,2]
[1,]    4    4
[2,]    4    4
> x %*% x
     [,1] [,2]
[1,]    8    8
[2,]    8    8

It's a little funny that 0^0 gives 1, but that's a reasonable
convention, often useful in likelihood calculations.

Duncan Murdoch




More information about the R-help mailing list