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
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
Emily Greulich
Emily Greulich 2020-2-26
Its a power law approximation and I'm trying to see the error between the approx and the orginial at different operating points. The orginial equation is F(X1, X2, X3) = X1 . exp(X2 + 2X3)

请先登录,再进行评论。

回答(1 个)

Jeff Miller
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.

类别

Help CenterFile Exchange 中查找有关 Particle Swarm 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by