Compute mean squared errors between data sets with the same vs different parameter values

조회 수: 11 (최근 30일)
Hello,
I have data stored in a n x n cell array. For example:
org_data = {rand(1000,1) rand(1000,1); rand(1000,1) rand(1000,1)};
In my data, the rows stand for different rounds and the columns stand for different parameter values. For example:
  • data{1,1} would be the data set for the first round of the first parameter value
  • data{2,1} would be the data set for the second round of the first parameter value
  • data{2,3} would be the data set for the second round of the third parameter value
  • etc.
My goal is to compute two things:
  • The average mean squared error within data sets which have the same parameter value
  • The average mean squared errors between data sets with different parameter values
To compute the two average mean squared errors I first need to compute it between every possible unique combination for the cells of my data. The resulting combinations in this case are:
  • data{1,1} & data{1,2}
  • data{1,1} & data{2,1}
  • data{1,1} & data{2,2}
  • data{1,2} & data{2,1}
  • data{1,2} & data{2,2}
  • data{2,1} & data{2,2}
To get all these combinations in MATLAB, I do the following:
org_data = {rand(1000,1) rand(1000,1); rand(1000,1) rand(1000,1)};
idx = 1:4;
c = nchoosek(idx,2);
data = org_data(c);
Now I want to compute the average mean squared error between all possible unique cell combinations. In this case, if computed manually, they would be the following:
% Compute mean squared errors between data sets with the same parameter values
a = immse(data{1,1}, data{2,1}); % parameter value #1
b = immse(data{1,2}, data{2,2}); % parameter value #2
same_par = mean([a b])
% Compute mean squared errors between data sets with different parameter values
c = immse(data{1,1}, data{1,2}); % parameter value #1 and #2, round 1 and round 1
d = immse(data{1,1}, data{2,2}); % parameter value #1 and #2, round 1 and round 2
e = immse(data{1,2}, data{2,1}); % parameter value #2 and #1, round 1 and round 2
f = immse(data{2,1}, data{2,2}); % parameter value #1 and #2, round 2 and round 2
diff_par = mean([c d e f])
I will work with larger cell arrays than in this example (e.g., 10 x 10 instead of 2 x 2). In those cases, I do not want to type out the combinations manually.
I am therefore trying to find a way / a function to automatize the process to get to same_par and diff_par. Can anyone help?
Thanks a lot in advance.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by