I have a matrix mat with values between 0 and 1 (so can be probabilities) as follows:
> t <- c(22, 65, 37, 84, 36, 14, 9, 19, 5, 49)
> x <- t/max(t)
> mat <- x%*%t(x)
I now want to convert this matrix b into a Markov transition matrix, i.e. have the elements of each row add up to 1. I achieve this by dividing the matrix by rowSums:
> y <- mat/rowSums(mat)
> z <- y/rowSums(y)
> rowSums(z)
[1] 1 1 1 1 1 1 1 1 1 1
However, this causes the elements in each column to have the same value:
[,1] [,2] [,3] [,4] [,5]
[1,] 0.06470588 0.1911765 0.1088235 0.2470588 0.1058824
[2,] 0.06470588 0.1911765 0.1088235 0.2470588 0.1058824
[3,] 0.06470588 0.1911765 0.1088235 0.2470588 0.1058824
[4,] 0.06470588 0.1911765 0.1088235 0.2470588 0.1058824
This is not what I want. I require each element to have different values but I'm not sure how to do this. Any suggestions appreciated!