문제

I don't know whether this is possible or not but let me explain my question

Imagine that I have the below array

errors=[e1,e2,e3];

Now what I want to calculate is below

MSE=1/(array_lenght)*[e1^2+e2^2+e3^2];

I can make this with a loop but I wonder if there is any quick way.

도움이 되었습니까?

해결책

This finds the mean of the squared errors:

MSE = mean(errors.^2)

Each element is squared separately, and then the mean of the resulting vector is found.

다른 팁

sum(errors.^2) / numel(errors)

Raising powers and adding can be done together instead of sequentially:

MSE = (errors*errors') / numel(errors)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top