Curve Fitting with multiple Y data point for each X

조회 수: 6 (최근 30일)
Pat
Pat 2013년 3월 28일
Hi I would like to fit a Gaussian curve to some data. The data are from 3 subjects and there are 7 x data points.
x = [-90 -45 -22.5 - 22.5 45 90] y = [0.3099 0.4806 0.5899 0.6836 0.6635 0.5841 0.2969; 0.2096 0.5600 0.2403 0.7877 0.8406 0.6927 0.2095; 0.1274 0.1973 0.1632 0.5383 0.6522 0.4410 0.1696];
I think I can do the fitting if I average across subjects first but I want to do the fit across all subjects 'at the same time'.
How can I do that??
Thanks for you help,
Pat

채택된 답변

Pat
Pat 2013년 3월 28일
Hi
1- You mean the fitted curve would look the same?
2- But what if I need to run some stats as I have another group of data that I need to compare it with?
I though I'd have more info if I run it at the same time across all the subjects!
Thanks

추가 답변 (1개)

Matt J
Matt J 2013년 3월 28일
I think I can do the fitting if I average across subjects first but I want to do the fit across all subjects 'at the same time'
The 2 results would be equivalent.
  댓글 수: 1
Matt J
Matt J 2013년 3월 28일
편집: Matt J 2013년 3월 28일
The fitted curve would be the same. If you fit "all the data" you are minimizing the following cost function with respect to x
sum_{i=[1,2,3]} [norm(F(x,xdata)-y_i)^2]/3
= sum_i [norm(F(x,xdata))^2 + 2*dot(F(x,xdata),y_i)]/3 + constant
= norm(F(x,xdata))^2 + 2*dot(F(x,xdata), sum_i y_i/3) + constant
= norm(F(x,xdata)-sum_i y_i/3)^2 +constant
This shows that minimizing the original curve fitting function is equivalent to minimizing
norm(F(x,xdata)-sum_i y_i/3)^2
which is the same as fitting the average of the data sum_i y_i/3.
I though I'd have more info if I run it at the same time across all the subjects!
You will have more info. The average over y_i will reflect that additional information.

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

카테고리

Help CenterFile Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by