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!