Search code examples
matlabstandard-deviationmse

Matlab: how to use mean square error and standard deviation in this example


I want to compare the error between y and yhat. y is generated using known values which are the coefficients of a Moving Average model. yhat is generated using estimates of the coefficients. What are the statistics which show how close the output are? In machine learning papers I have seen standard deviation and mean square error as the performance metric. But I cannot understand how I can apply these in this example. Any guidance will be very helpful. Thankyou.

N = 100;
a1=0.2;
b1=0.5;
h = [1 a1 b1]; %channel coefficients
h_hat  = [1 0.23 0.45];
data = rand(1,N);
y = filter(h,1,data); %transmitted signal through MA channel
yhat = filter(h_hat,1,data);

Solution

  • How to calculate MSE:

    MES= mean((y - yhat).^2)
    

    And here the standard error of the mean:

    err=y - yhat;
    SE = std(err)/sqrt(length(err));
    

    However, the metric you are using should address your research question/ hypothesis. It might be that SE or MSE are not the right choices. Without knowing what you are investigating it is difficult to give any suggestions.