f

#### Least square fitting

```Hi,

I have this graph:

x = [0.000235 0.00025 0.0003 0.0004 0.0005 0.0006 0.00075]
y = [54.9 43.1 62.7 86.3 86.3 90.2 96.1]

plot (x, y)
xlabel ('Amplitude')
ylabel ('Correct Detection [%]')
legend ('Psychometric Function')

and I want to fit it to this equation:

P(A, 'theta') = [1/sqrt(2*pi*sigma²)] * integral e^-[(A-'theta'²)/2*sigma²]

how can i do this?

thank you.
```
 0
xety89
4/22/2010 7:45:21 AM
comp.soft-sys.matlab 211266 articles. 25 followers. lunamoonmoon (257) is leader.

2 Replies
618 Views

Similar Articles

[PageSpeed] 25

```"xety89 " <sow.chan@warwick.ac.uk> wrote in message <hqouqh\$snf\$1@fred.mathworks.com>...
> Hi,
>
> I have this graph:
>
> x = [0.000235 0.00025 0.0003 0.0004 0.0005 0.0006 0.00075]
> y = [54.9 43.1 62.7 86.3 86.3 90.2 96.1]
>
> plot (x, y)
> xlabel ('Amplitude')
> ylabel ('Correct Detection [%]')
> legend ('Psychometric Function')
>
> and I want to fit it to this equation:
>
> P(A, 'theta') = [1/sqrt(2*pi*sigma²)] * integral e^-[(A-'theta'²)/2*sigma²]
>
> how can i do this?

Hmm. I have a funny feeling that your expression
is wrong. Everything about that expression is a
simple, cumulative normal, except for that you
square theta, as opposed to squaring the difference
(A-theta).

Beyond that, your expression is not meaningful in
terms of the data that you have. You are talking
about doing some sort of a nonlinear least squares
fit to that expression, but that expression cannot
yield any numbers that are even reasonably close to
the data that you pose. My guess is that you wish
to scale and shift this curve, using that general

Note that a nice way to obtain this cumulative
normal shape (if you don't have the stats toolbox)
is to use erf. If you do have the stats TB, then call
normcdf. NEVER do the integration yourself using

John
```
 0
John
4/22/2010 9:21:08 AM
```You can also use the ezyfit toolbox.
http://www.mathworks.com/matlabcentral/fileexchange/10176-ezyfit-2-30

Recognising the error function, you can fit your data with
>> showfit('P(A) = 100*erf((A-theta)/sigma); sigma=1e-4; theta=1e-4');

yielding:
sigma = 0.00040156
theta = 4.8345e-005

Frederic.

"xety89 " <sow.chan@warwick.ac.uk> wrote in message <hqouqh\$snf\$1@fred.mathworks.com>...
> Hi,
>
> I have this graph:
>
> x = [0.000235 0.00025 0.0003 0.0004 0.0005 0.0006 0.00075]
> y = [54.9 43.1 62.7 86.3 86.3 90.2 96.1]
>
> plot (x, y)
> xlabel ('Amplitude')
> ylabel ('Correct Detection [%]')
> legend ('Psychometric Function')
>
> and I want to fit it to this equation:
>
> P(A, 'theta') = [1/sqrt(2*pi*sigma²)] * integral e^-[(A-'theta'²)/2*sigma²]
>
> how can i do this?
>
> thank you.
```
 0
Frederic
4/22/2010 6:45:11 PM

Similar Artilces:

Global least squares fit in MATLAB?
Hello, Is it possible to simultaneously fit multiple data sets, with some imposed constraints relating the fit parameters across the different data sets? Thanks. Yes, of course. You might have to use a general nonlinear solver though. NLSSOL can handle a least squares formulation with general linear/ nonlinear constraints. Best wishes, Marcus http://tomopt.com/ http://tomsym.com/ Kevin Kung wrote: > Is it possible to simultaneously fit multiple data sets, with some imposed constraints relating the fit parameters across the different data sets? If I understand your question correctl...

Matlab: least square fit with more than one variables
Hello, Is there anyone can help me with the following problem in Matlab? Suppose I have a function: sqrt((1/N)*sum((x+(a+b*x+c*x*x)*(y-800)-z)^2)), where N is number of data points, x,y,z are known experiment data (1D arrays with same size) which can be read from file. Will need to find a,b,c so the above function is minimized. Any help is highly appreciated. Thanks On Jun 7, 9:39=A0am, itubeusa <itube...@yahoo.com> wrote: > Hello, > Is there anyone can help me with the following problem in Matlab? > Suppose I have a function: > > sqrt((1/N)*sum((x+(a+b*x+c*x*x)*(y-800)...

Is there any nonnegative least square fitting functions available from matlab?
Hi guys, For A*x = b for example, for A being a matrix 10 by 4, x and b are vectors with 4 elements. How can I get the least square result of x with the nonnegative constraint? Thanks alot Check out lsqnonneg. -marcelo hnliuhy wrote: > Hi guys, > For > A*x = b > for example, for A being a matrix 10 by 4, x and b are vectors with > 4 elements. > > How can I get the least square result of x with > the nonnegative constraint? > > Thanks alot ...

Least-squares fitting a square pulse
I am trying to fit a square pulse to data in the least-squares sense in Matlab. The parameters that are being optimized are the height, start, and end - x(1), x(2) and x(3) in the program, respectively. However, the least-squares program is only varying the height, for some reason. Why is this occurring? How else could I fit a square pulse using least-squares? Although in this example the pulse would be easy to fit by inspection, for the purpose of my project, it is not an option. Code: %FITTING xdata=0:0.1:10; ydata=-.05+.1*rand(1,numel(xdata))+heaviside1(xdata-1)-heaviside1(xdata-4);...

Adding constraints to linear fit parameters of separable least squares fit
I was wondering if anyone can help me to figure out how to add equality and inequality constraints to the linear parts of a separable least squares fit. I saw fminspleas is able to do it for the nonlinear fit parameters (using transformations from a constrained problem to an unconstrained one), but not for the linear fit parameters. Here is my code for the separable least squares fit. Thanks. function[NLP,LP,res]=seplstsq(funlist,start_point,xdata,ydata,options) function [sse,LP,res]=seplstsq_sse(NLP) DM=zeros(length(ydata),length(funlist)); for ii=1:length(funlist); f...

Least Square Fit
I tried to use lsqlin to do a least square fit with 3 constraints. I had 7 variables. However it didn't seem to take into account the last 2 cosntraints. I am trying to use fmincon but keep getting an error 'Inner matrix dimensions must agree'- I checked the dimensions of the constraint and Obj function matrices.but Ican't figure out why this is happening. Help! In article <eee31fe.-1@webx.raydaftYaTP>, "Shar P" <sprabhu@ieor.berkeley.edu> writes: >I tried to use lsqlin to do a least square fit with 3 constraints. I >had 7 variables. However it ...

Least squares fitting
Hello everybody, I am working on an inverse problem where I need to use least squares fitting. I am working on characterization of impedance of a piezoelectric crystal. A PZT crystal can be modeled as a series RLC circuit in parallel with a parasitic capacitor. Thus, I can derive the transfer function of its impedance and admittance and simulate it (see the code below) I am trying to extract R,L,C and C0 parameters from this simulated admittance curves using least squares fitting method.( Also, I need to inversely calculate these from the admittance curves that are constructed using ...

least squares fit
I'm trying to solve a system of 5+ equations for 3 unknowns, preferably using the least-squares method. I've Solve[] will not return solutions for more equations than you have unknowns. Fit[] does not work because my equations have 4 sets of data. Si=a*Ui + b*Vi + c*Wi, where i goes from 1 to 5 U, V, and W all come from a table, and S is from experimental data. I need to know how to solve for a,b,c given more than 3 equations. Background: The problem is actually trying to solve for Judd-Ofelt parameters of a laser crystal. S is the experimental line strength and U, V...

least square fit
Hi I have many file with extension (.dat). I need to open them in IDL and have least square fit. Is any one have idea on who to that. omerphysics@gmail.com writes: > I have many file with extension (.dat). I need to open them in IDL and > have least square fit. > Is any one have idea on who to that. Well, rest assured, the code will be less than 10 lines long. But, *which* 10 lines will depend on more details. What do you know about this problem? You can find a lot of hints at the web page below. Cheers, David -- David Fanning, Ph.D. Fanning Software Consulting, Inc. Coyote'...

least square fitting
dear Gnuplot users, I am using the following command to fit a set of data: f(x)=a*x+b; fit f(x) 'dataset' via a,b then I get the value of a and b with only one decimal digit like a=0.1, b=0.9 how can I get five decimal digits like a=0.00001, b=0.91112 ? Thanks David <dagao@exchange.uta.edu> wrote: > dear Gnuplot users, > I am using the following command to fit a set of data: > f(x)=a*x+b; > fit f(x) 'dataset' via a,b > then I get the value of a and b with only one decimal digit like a=0.1, > b=0.9 "get the value" --- where? All the outputs of 'fit' I'm aware of print with a good deal more than 1 significant digit. Well, unless all the others following it *are* exactly zero, that is. -- Hans-Bernhard Broeker (broeker@physik.rwth-aachen.de) Even if all the snow were burnt, ashes would remain. Below is the copy: Final set of parameters Asymptotic Standard Error ======================= ========================== a = 0.0751221 +/- 0.005317 (7.078%) b = -29512.8 +/- 0.001603 (5.432e-06%) correlation matrix of the fit parameters: a b a 1.000 b -0.905 1.000 you can notice b= -29512.8 only has one decimal value. How to change it to have more than 1 decimal digit? Thanks David <dagao@exchange.uta.edu> wrote: > Below is the c...

least square fit
I have the following data file: http://www.cs.kuleuven.ac.be/~bartv/gnuplot/sobol.dat Now I want to do a least square fit on the data of the first and second column. The data in the first-column represent the x-values, the data in the second column represent the y-values. I don't need the rest of the columns. Now I now that x and y are related somehow as: y = a/(x**b) and I want to find a and b as accurate as possible. The file that plots my data to an .eps file is at http://www.cs.kuleuven.ac.be/~bartv/gnuplot/relative_error.pl If I don't specify an initial value for b_sob, the fit fails. If I do specify a starting value of 0.9 the fit works, but the result is not satisfying as can be seen from the .eps file at http://www.cs.kuleuven.ac.be/~bartv/gnuplot/relative_error.eps I have also tried to fit on log(\$2)=a-b*log(\$1) and then plot exp(a)/(x**b) but this didn't give me satisfying results either. How can I increase the quality of my fit? Regards, Bart -- "Share what you know. Learn what you don't." Bart Vandewoestyne wrote: > I have the following data file: > > http://www.cs.kuleuven.ac.be/~bartv/gnuplot/sobol.dat > > Now I want to do a least square fit on the data of the first and > second column. The data in the first-column represent the x-values, the > data in the second column represent the y-values. I don't need the rest > of the columns. > &...

Least Squares Fitting #3
I am in need of some help. I am fitting Gaussian curves using the curve fitting toolbox. Once I fit the curve I get a x_0 centroid and a width. My goal is to fit the centroids of five different curves. I would like to fit the following and generate a slope and intercept. I am unable to do this is MATLAB. x y upper_y lower_y ..511 108 109.4 107.3 1.275 280 283 280 .... ..... ..... ..... .... ..... ..... so on and so ...

NonLinear least square fit
Iam using the lsqcurvefit function to estimate some parameters by fitting a kinetic model to experimental data.I need to get an estimate of the errors for the individual parameters that are calculated by the program.The function lsqcurvefit returns residuals but does not provide any estimates for the standard deviations for the parameters calculated.Iam sure there is a way of calculating them.Can someone please help? Thanks. Farah Bardai wrote: > > > Iam using the lsqcurvefit function to estimate some parameters by > fitting a kinetic model to experimental data.I need to get an &g...

Least squares fitting #2
I need to find the coefficients k1-k6 of the following equation: P = G*(k1 + k2*T + k3*log(G) + k4*(log(G)).^2 + k5*T*log(G)+ k6*T*(log(G)).^2+k7*T.^2); The experimental data I have are P, G and T. Is there any MATLAB function in order to obtain the coefficients using least-squares fitting? Do I need the Curve Fitting Toolbox? Thank you very much, Zaira "Zaira " <Zaira.Girbau-Garcia@jrc.it> wrote in message <g0ccfp\$jd9\$1@fred.mathworks.com>... > I need to find the coefficients k1-k6 of the following equation: > > P = G*(k1 + k2*T + ...

Least Squares Surface Fitting
Dear all, I'm a beginner of Matlab using. I have to find out how to fit a surface of 2 dimensional scatterd data in a least squares sense. Are there alreay toolboxes or functions to provide that? Can anybody help and give me more information? Thankx a lot Lukas Lukas wrote: > > > Dear all, > > I'm a beginner of Matlab using. > I have to find out how to fit a surface of 2 dimensional scatterd > data in a least squares sense. > > Are there alreay toolboxes or functions to provide that? > Can anybody help and give me more information? > > Thankx a l...

nonlinear least squares fit
Hi, I am trying to solve an optimization problem in Matlab. It is a nonlinear least squares problem. The goal is to derive the best-fit equations of seven straight lines (and other standard output e.g. residuals etc.). I've posted the problem description, and two images, one that describes the problem setting in detail, the other showing the set of 3D points I plotted for this, all here:: http://sites.google.com/site/niazarifin/matlab-project-images Since I never used any optimizer before, I'd truly appreciate if you can help on: 1.which Matlab function to use for the problem 2.what f...

Least square plane fitting
Hello, i'm a student of University of Parma (Italy), and i've the following problem. I've found in internet the following model for fitting a plane from a cloud of point 3D. The link to the page is [ http://www.bmm.icnet.uk/people/suhail/plane.html ]. I've implemented this model in C++ and i've obtained some good result but when i try to reconstruct the passages of the procedure i'm not able to obtain the resulting matrix 3x3 denoted as W in the follow. I want to know if something one can help me to resolve this problem. I've tried to contact the author of the mod...

Least squares fit with matrices
Hi, I have equation: X=a_1*Y_1+a_2*Y_2+a_3*Y_3... where size(Y_n)=size(X)=[100 100] and size(a_n)=[1 1] X and Y_n are constants How can I do some kind of least squares fit to determine a_n? -Jonne Jonne wrote: > > > Hi, > > I have equation: > > X=a_1*Y_1+a_2*Y_2+a_3*Y_3... > > where size(Y_n)=size(X)=[100 100] and size(a_n)=[1 1] > X and Y_n are constants > > How can I do some kind of least squares fit to determine a_n? > > -Jonne A = [Y1(:),Y2(:),Y3(:)]\X(:); HTH, John ...

least square fit #4
I tried to fit data to get the sig and mean parameters of the gaussian distribution. I found lsqcurvefit can only get the correct fitting result of sig but not for the mean. The mean is always the initial value you set for the fitting. Any input is highly appreciated. TG My code is very simple. Is there something wrong with it? -------------------- function rst=fit_test() % % % xdata=1:1000; meandata=400; sigdata=50; ydata=gaussmf(xdata,[sigdata, meandata]); a=figure; hold on; plot(xdata,ydata) x0=[100,10]; lb=[1,1]; ub=[1000, 1000]; options=optimset('MaxFunEvals',1000,'MaxIter&...

Least square fit #2
Hi, I have performed a least-square fit script file with the input data comes from the user-specified input data file, which means that the input data is saved as .m file. so that the data to be calculated is not key in using the keyboard. My question is, why MATLAB calculate only 8 points instead on 9 points given in the .m file: example: 4.672 7.143 1.667 6.944 1.389 1.042 1.515 5.996 1.389 6.667 2.000 11.906 4.545 14.286 5.556 1.053 8.333 25.00 since MATLAB use 8 points instead of 9, the slope and intercept is not accurate. I've compared the result with Excel. Can anybody assist me ...

Uncertainty in least square fits
Hi! I am using polyfit for a set of my data points which is fitted to a parabolic curve as y=p2*x^2+p1*x+p0. I am not quite sure how to extract the uncertainties associated with each of these polynomials. I know the algorithm from the least square fit procedure, but I'd like to know if Matlab has a built-in function for this. Eventually, I would have to fit the data points using a high-order polynomial, so it would be useful to know how to estimate the errors at this stage. "Woo-Joong Kim" <andy78521@hotmail.com> wrote in message <fe1fj9 \$91n\$1@fred.mathworks....

Weight least square fit
Hi everyone. A quick description of my problem: I have 4 sensor measurements (x_sensor), which can be estimated using a numerical model (nb the model is nonlinear is solved numerically...) I wish to fit the parameters of my model to best represent the measured data by performing a weighted least square fit with a different weighting for each sensor (due to different noise in the measurements). i.e. an objective function: error = A(x1_sensor - x1_model) + B(x2_sensor - x2_model) + C(x3_sensor - x3_model) + D(x4_sensor - x4_model) I am currently using lsqcurvefit but get a bad fit due to so...

least squares curve fit
Hi I'm trying to write a program that takes data points and solves for coefficients for a least squares curve fit using matrices and starting from an initial condition. I tried building the coefficient matrix and solving for the coefficients but I end up with a straight line. Any advice would be appreciated. In article <eeed0b8.-1@webx.raydaftYaTP>, "John Roth" <jrothml@yahoo.com> writes: >Hi I'm trying to write a program that takes data points and solves >for coefficients for a least squares curve fit using matrices and which type of curve ? which type...

Web resources about - Least square fitting - comp.soft-sys.matlab

Form-fitting garment - Wikipedia, the free encyclopedia
A form-fitting garment is an article of clothing that tightly follows the contours of the part of the body being covered. There are numerous ...

Glass fittings for iPhone, iPod touch, and iPad on the iTunes App Store
Get Glass fittings on the App Store. See screenshots and ratings, and read customer reviews.

YouTube - Jackie Brown (7/12) Movie CLIP - Fitting Room Exchange (1997) HD
Hochgeladen am 27.09.2011 Jackie Brown Movie Clip - watch all clips http://j.mp/Awgue0 click to subscribe http://j.mp/sNDUs5 Jackie (Pam Grier) ...

New Lion Jordon Bourke to make a fitting debut
Jordon Bourke will become Brisbane's 10th debutant for the season.&#160;

Football fever just a game of fitting in
Were you up early cheering the Socceroos on? You may not be a football fanatic, just trying to fit in, according to a Canberra sports psychologist. ...

Fast and Furious 7 review: Fitting farewell to Paul Walker from high-speed franchise
With his first big-budget action debut, James Wan has found an appropriate, well-judged way to farewell the franchise's star, Paul Walker, and ...

Sanitary products handed out by male guards, asylum seekers given ill-fitting clothing on Nauru, Senate ...
Female asylum seekers on&nbsp;Nauru were denied easy access to sanitary pads for &quot;security reasons&quot;, an elderly female detainee was ...

Rugby World Cup 2015 final: Dan Carter gets fitting end to All Blacks career
It was the stage fit for a hero and Dan Carter stepped up for New Zealand as the champion playmaker erased the injury heartbreak of missing the ...

Geminids meteor shower to provide a fitting end to International Year of Light
This year's Geminids meteor shower should provide a fittingly spectacular finale to the International Year of Light with an estimated 150 meteors ...

Resources last updated: 3/2/2016 11:48:47 PM