On Sun, May 19, 2013 at 5:04 PM, Gabor Grothendieck
<ggrothendi...@gmail.com> wrote:
> On Sun, May 19, 2013 at 4:57 PM, Gabor Grothendieck
> <ggrothendi...@gmail.com> wrote:
>> On Sun, May 19, 2013 at 10:33 AM, mary <mary.d...@libero.it> wrote:
>>>
>>> Sorry in the previuos message I've inverted:  I would like generate ...
>>> "same eigenvectors and different eigenvalues"
>>
>> Try this:
>>
>> m0 <- 5 + matrix(c(.05, -.05, -.05, .05), 2)
>> m0.values <- eigen(m0)$values
>> with(eigen(matrix(rnorm(4), 2)), vectors %*% diag(m0.values) %*% 
>> solve(vectors))
>
> I think I reversed it too.  If that's not it try this:
>
> m0.vectors <- eigen(m0)$vectors
> with(eigen(matrix(rnorm(4), 2)), m0.vectors %*% diag(values) %*%
> solve(m0.vectors.0))
>

That did not take into account the positive definite requirement. Try this:

m0.vectors <- eigen(m0)$vectors
t.m0.vectors <- t(m0.vectors)
n <- 3 # no of samples
tmp <- apply(rWishart(n, 2, diag(2)), 3, function(w) list(m0.vectors
%*% diag(eigen(w)$values) %*% t.m0.vectors))
simplify2array(tmp)

The result is a list of matrices.


--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to