### Re: Being stupid - need help

Hi, I may be being equally stupid, and hopefully this will stimulate some thought rather than just a solution, but your mean squared error formula seems to be different to the .js one

```-- Calculates the mean squared error
public function MeanSquaredError(sequence truth, sequence prediction)
atom rss = 0.0
for i = 1 to length(truth) do
rss += msqrt(truth[i] - prediction[i])
end for
return abs(rss / length(truth))
end function
```
```exports.HoltWintersSmoothing.prototype.computeMeanSquaredError = function()
{
var SSE = 0.0;
var n = 0;
for(var i = 0; i < this.data.length; ++i)
{
if(this.data[i] != null && this.forecast[i] != null)
{
SSE += Math.pow(this.data[i] - this.forecast[i], 2);
n++;
}

}
return 1/(n-1)*SSE;
};
```

I might have tried

```-- Calculates the mean squared error
public function MeanSquaredError(sequence truth, sequence prediction)
atom rss = 0.0
integer n = 0
for i = 1 to length(truth) do
if truth[i] !=0 and prediction[i] !=0 then   --assumes that truth and prediction are same lenghts/elements
rss += power(truth[i] - prediction[i], 2)
n += 1
end if
end for
return 1/(n-1) * rss     --better check that n>1
end function
```

Anyway just a thought.

Chris

Not signed in.