Sum Squared Errors for 3 parameters
1 回表示 (過去 30 日間)
古いコメントを表示
Im trying to find the sum of squared errors (SSE) for two equations with 3 parameters. Im using nested for loops but I'm getting a massive number and its not stepping through the parameters correctly.
Here is the entire code. I need help with the for loops and getting them to work right.
%
e = 2.71828;
%X1=X2=X3
OP = 1;
%exponents
g = 1;
h = OP;
i = 2*OP;
%alpha
a = (e^(OP+2*OP))/(OP^(g-1) * OP^h * OP^i);
%SSE
E = 0;
SSE = 0;
for X1 = 0:10
for X2 = 0:10
for X3 = 0:10
end
end
F = a*X1*X2*X3^2;
f = X1*e^(X2+2*X3);
E = (f - F)^2;
SSE = SSE + E
end
2 件のコメント
Naveed Ahmed
2020 年 2 月 26 日
Hi
Apparently there does not seem to be any issue with the code, as it is doing as coded. Practically speaking, SSE is calculated with actual and predicted values, both of these are calculated in your code that are presumable f and F. Since you are taking cube and taking exponential, it is expected that value would be high. So, to answer you better, can you elaborate bit more about the nature of f and F and how do you come up with these equations?
Good Luck
回答 (1 件)
Jeff Miller
2020 年 2 月 27 日
It looks like your X2 and X3 'for' loops aren't doing anything, since there is no code between their 'for' and 'end' statements. Not sure what you are actually trying to compute, but it looks like it would make more sense to move the computation statements (computing F down to SSE) before those two end statements.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Particle Swarm についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!