필터 지우기
필터 지우기

Polynomial Fit from a high Deviation set of feature experiments

조회 수: 1 (최근 30일)
kuku hello
kuku hello 2022년 5월 3일
편집: Matt J 2022년 5월 3일
I am doing a number of experiments to evaluate a feature in different points in time, the result of each experiment have a high error value or a big standard deviation. I know that by taking a point from each experiment I should be able to create a linear fit. So I need to create an algorithm which is able to pick the right feature evaluations in order to form a linear fit with minimum error (with the least mean square error from the line as possible).
For example I have the following experiments:
exp1 = [10,9,11,8];
exp2 = [5,7,5,9];
exp3 = [2,4,3,2];
exp4 = [-4,-2,-3,-1];
I want to pick one point (single feature evaluation) from each experiment, and from the points taken from every experiment, to make a linear fit with minimum deviation as possible.
So in the example case In order to create a line without any deviation I will choose the set of points [8,5,2,-1]. Each point is measured in different experiment and doing a linear fit I can make a perfect line of feature vs experiment number. If I'll choose point 11 from exp1 and -4 from exp4 the line would have a higher deviation (MSE) from the line chosen above.
Any help?
Thanks in advance.
  댓글 수: 2
Matt J
Matt J 2022년 5월 3일
So in the example case In order to create a line without any deviation I will choose the set of points [8,5,2,-1].
I hope you know that the solution is not unique. Another solution here is [11,7,3,-1],
plot([11,7,3,-1],'-o')
kuku hello
kuku hello 2022년 5월 3일
Thanks, thats ok the solution doesn't have to be unique. If I have the option to see all of the options it would be great.

댓글을 달려면 로그인하십시오.

채택된 답변

Matt J
Matt J 2022년 5월 3일
편집: Matt J 2022년 5월 3일
expData = {[10,9,11,8];
[5,7,5,9];
[2,4,3,2];
[-4,-2,-3,-1]};
[Y{1:4}]=ndgrid(expData{:});
N=numel(Y);
Y=reshape( cat(N+1,Y{:}) ,[],N)';
X=[1:N;ones(1,N)]';
SE=vecnorm(X*(X\Y)-Y,2,1);%L2 error
minSE=min( SE ); %min. L2 error
AllSolutions=unique(Y(:,abs(SE-minSE)<=1e-10*minSE)','rows')'
AllSolutions = 4×2
8 11 5 7 2 3 -1 -1
  댓글 수: 2
kuku hello
kuku hello 2022년 5월 3일
Wow thanks it looks like it works but can I have further information about the role of X? I'll admit this code seems to be high level programming :P.
Matt J
Matt J 2022년 5월 3일
편집: Matt J 2022년 5월 3일
The equation for a line is y=m*x+b, which can be written in matrix multiplication form,
[x,1]*[m;b]=y
If you have many x(i) and y(i), this becomes,
[x1,1;
x2,1;
...
xN,1]*[m;b]=[y1;y2;y3;...;yN]
The Nx2 matrix on the left hand side is X, the Nx1 vector on the right hand side is Y, and the solution for [m;b] is X\Y.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by