What's the octave equivalent of eig(X, 'nobalance')

我的梦境 提交于 2019-12-08 02:07:50

问题


I'm trying to find the equilibrium distribution of a markov chain, which means finding the eigenvalues of the transition matrix representing it, however, the eig function automatically normalises the eigenvectors it returns, in MatLab there is a flag you can pass to the function to stop this behaviour

eig(X, 'nobalance')

Where X is a matrix. See http://www.mathworks.com/help/techdoc/ref/eig.html. However, when I try this in octave I just get an error:

error: eig: wrong type argument `sq_string'

Is there some other function I should be calling?

Cheers


回答1:


If your goal is to compute the equilibrium distribution of a Markov chain, take a look at the mcStatDist function implementation from the PMTK3 toolbox. It shows four different ways to compute the result. Example:

TR = rand(3,3);                          %# random transition matrix
TR = bsxfun(@rdivide, TR, sum(TR,2));    %# normalize so that rows sum to one

[V,D] = eig(TR');                        %'# eigen-decomposition
EQ = V(:,1) ./ sum(V(:,1));              %# state equilibrium distribution

As noted in the comments of the linked code, this method can be numerically unstable for some cases, so you might want to consider one of the other options...



来源:https://stackoverflow.com/questions/4173860/whats-the-octave-equivalent-of-eigx-nobalance

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!