Sum Squared Errors for 3 parameters
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Naveed Ahmed
el 26 de Feb. de 2020
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
Respuestas (1)
Jeff Miller
el 27 de Feb. de 2020
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 comentarios
Ver también
Categorías
Más información sobre Particle Swarm en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!