# [R] Generating a stochastic matrix with a specified second dominant eigenvalue

Albyn Jones jones at reed.edu
Fri Oct 16 00:56:27 CEST 2009

I just tried the following shot in the dark:

generate an N by N stochastic matrix, M.  I used

M = matrix(runif(9),nrow=3)
M = M/apply(M,1,sum)
e=eigen(M)
e$values[2]= .7 (pick your favorite lambda, you may need to fiddle with the others to guarantee this is second largest.) Q = e$vectors
Qi = solve(Q)
B = Q %*% diag(e$values) %*% Qi > eigen(B)$values
[1]  1.00000000  0.70000000 -0.08518772
> apply(B,1,sum)
[1] 1 1 1

I haven't proven that this must work, but it seems to.  Since you can
verify that it worked afterwards, perhaps the proof is in the pudding.

albyn

On Thu, Oct 15, 2009 at 06:24:20PM -0400, Ravi Varadhan wrote:
> Hi,
>
>
>
> Given a positive integer N, and a real number \lambda such that 0 < \lambda
> < 1,  I would like to generate an N by N stochastic matrix (a matrix with
> all the rows summing to 1), such that it has the second largest eigenvalue
> equal to \lambda (Note: the dominant eigenvalue of a stochastic matrix is
> 1).
>
>
>
> I don't care what the other eigenvalues are.  The second eigenvalue is
> important in that it governs the rate at which the random process given by
> the stochastic matrix converges to its stationary distribution.
>
>
>
> Does anyone know of an algorithm to do this?
>
>
>
> Thanks for any help,
>
> Ravi.
>
> ----------------------------------------------------------------------------
> -------
>
>
> Assistant Professor, The Center on Aging and Health
>
> Division of Geriatric Medicine and Gerontology
>
> Johns Hopkins University
>
> Ph: (410) 502-2619
>
> Fax: (410) 614-9625
>
>
> Webpage:
> html>
> tml
>
>
>
> ----------------------------------------------------------------------------
> --------
>
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help