Curve Fitting with multiple Y data point for each X

4 次查看(过去 30 天)
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