Ältere Kommentare anzeigen
Hello,
I am currently writing a MCMC code. Here is what I have so far:-
clear all
s = load('domain name on my computer.txt');
x = s(:,2);
y = s(:,3);
for q = 1:1000
a = 9.9840;
b = 9.9939;
c(q) = a + (b-a) * rand;
d = 5.0040;
e = 5.0139;
f(q) = d + (d-e) * rand;
chi2P1(q) = sum((y - (c(q)+(f(q).*x))).^2);
g = 0;
h = 1;
i(q) = abs(g + (h-g)*randn);
j(q) = c(q)+i(q);
k(q) = f(q)+i(q);
chi2PN(q) = sum((y - (j(q)+(k(q).*x))).^2);
if (chi2PN(q)<=chi2P1(q));
elseif (chi2PN(q)>=chi2P1(q));
end
end
At the point of the if loop I am stuck. If j and k values give a smaller chi2PN value than chi2P1 (dependent on c and f) how would I make j and k become the new c and f?
Also if this isn't the case how would I disregard the j and k values?
Hope this makes sense and thanks for taking a look at my problem.
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!