setinitialstate.m.txt

来自「这是马尔可夫-蒙特卡罗算法的MATLAB源程序.」· 文本 代码 · 共 43 行

TXT
43
字号
function p = SetInitialState(d,m,pperm,rperm)
% p = SetInitialState(d,m,pperm,rperm)
% Set the initial state for the Rnet sampler.
% Input is data structure (for network topology), model m, and
% permutsations for solver
%
% The state p is a structure that contains:
% DR:            a sparse matrix of (un)directed resistances (upper triangular)
% G:             column m is the the Green's functions for electrode #m 
% logPrior:      log of value of the prior
% logLikelihood: log of value of the Likelihood

% Colin Fox, 29 Nov 2005

r0 = m.Resistances(1); % initial resistor value

[nnps,nnodes,nres,nbn]=nodenums(d.N);

% first set up connectivity matrix of directed resistances (as sparse matrix)
DR = sparse([],[],[],nnodes,nnodes,nres); % initialise matrix of resistances

for rcount = 1:nnps % loop over rows of network
    for count = 1:d.N % loop over resistors in a row
        snode = (rcount-1)*nnps + count; % start node
%        DR(snode,snode+1) = r0; 
        DR(snode,snode+1) = PickOne(m.Resistances); % random intial state
    end
end
for ccount = 1:nnps % loop over columns of network
    for count = 1:d.N % loop over resistors in a column
        snode = ccount + (count-1)*nnps; % start node
%        DR(snode,snode+nnps) = r0; 
        DR(snode,snode+nnps) = PickOne(m.Resistances); % random intial state
    end
end

%DR=d.trueDR; % start at true state

G = Solver(DR,d,pperm,rperm);
p = struct('DR',DR,'G',G);
% set prior and Likelihood
[p.logPrior,p.BoolDif] = logPrior(p,m,d.lic);
p.logLikelihood = logLikelihood(p,d);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?