From: David Heslop on
"Steven Lord" <slord(a)mathworks.com> wrote in message <hin8vi$b3m$1(a)fred.mathworks.com>...
>
> "David Heslop" <david_heslop(a)xyz.com> wrote in message
> news:himl76$2ne$1(a)fred.mathworks.com...
> > Hi all,
> > I&#8217;m working with experimental data which is represented as a series
> > of x and y values (both x and y are non-negative), which when plotted give
> > a curved form. I know from theory that they should follow a hyperbolic
> > curve of the form Ax+Bxy+Cy+D=0 and the question is how to determine A, B,
> > C and D for the best-fit hyperbola through the data. Currently I&#8217;m
> > using fminsearch to minimize the function:
> >
> > function rs = myfun(coef,x,y)
> > rs=[x x.*y y ones(size(x))]*coef;
> > rs=sum(rs.^2);
> >
> > Where coef is a 4 element column vector containing A, B, C and D. This
> > seems to work okay sometimes, but of course is very sensitive to the
> > initial choices of the coefficients and I really don&#8217;t know how
> > robust such an approach is. Does anyone have any suggestions on a more
> > suitable way to fit such a function?
>
> I would try to transform this into a problem of the form M*coeffs = 0 and
> use NULL.
>
> --
> Steve Lord
> slord(a)mathworks.com
> comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
>
Hi Steve,
thanks for the advice. NULL does work very well in the case of zero noise, but as soon as I add some noise to the data (even very small amounts) NULL returns an empty vector. Is there a way around this problem?
thanks, Dave
From: Torsten Hennig on
> Torsten Hennig <Torsten.Hennig(a)umsicht.fhg.de> wrote
> in message
> <232688810.68193.1263464973633.JavaMail.root(a)gallium.m
> athforum.org>...
> > > Hi all,
> > > I'm working with experimental data which is
> > > represented as a series of x and y values (both x
> and
> > > y are non-negative), which when plotted give a
> curved
> > > form. I know from theory that they should follow
> a
> > > hyperbolic curve of the form Ax+Bxy+Cy+D=0 and
> the
> > > question is how to determine A, B, C and D for
> the
> > > best-fit hyperbola through the data. Currently
> > > I'm using fminsearch to minimize the
> function:
> > >
> > > function rs = myfun(coef,x,y)
> > > rs=[x x.*y y ones(size(x))]*coef;
> > > rs=sum(rs.^2);
> > >
> > > Where coef is a 4 element column vector
> containing A,
> > > B, C and D. This seems to work okay sometimes,
> but of
> > > course is very sensitive to the initial choices
> of
> > > the coefficients and I really don't know
> how
> > > robust such an approach is. Does anyone have any
> > > suggestions on a more suitable way to fit such a
> > > function?
> > >
> > > Thanks, Dave
> >
> > By the way:
> > For the function you are trying to minimize
> > (A,B,C,D) = (0,0,0,0) is always a solution -
> > and that's not what you want, I guess.
> >
> > Best wishes
> > Torsten.
>
> Hi Torsten
> Your right, (A,B,C,D) = (0,0,0,0) isn't what I want.
> I tried the method you suggested and it works really
> nicely. One issue appears when I artificially add
> relatively small amounts of noise to the system (just
> scaled normally distributed random numbers). Then the
> fit can be a long way from the data, any suggestions?
>
> thanks for your help, Dave

The estimated parameters should depend continuously
on the input data.
Maybe an error in your code ?

Best wishes
Torsten.
From: David Heslop on
Torsten Hennig <Torsten.Hennig(a)umsicht.fhg.de> wrote in message <1988820970.73186.1263540202253.JavaMail.root(a)gallium.mathforum.org>...
> > Torsten Hennig <Torsten.Hennig(a)umsicht.fhg.de> wrote
> > in message
> > <232688810.68193.1263464973633.JavaMail.root(a)gallium.m
> > athforum.org>...
> > > > Hi all,
> > > > I&#8217;m working with experimental data which is
> > > > represented as a series of x and y values (both x
> > and
> > > > y are non-negative), which when plotted give a
> > curved
> > > > form. I know from theory that they should follow
> > a
> > > > hyperbolic curve of the form Ax+Bxy+Cy+D=0 and
> > the
> > > > question is how to determine A, B, C and D for
> > the
> > > > best-fit hyperbola through the data. Currently
> > > > I&#8217;m using fminsearch to minimize the
> > function:
> > > >
> > > > function rs = myfun(coef,x,y)
> > > > rs=[x x.*y y ones(size(x))]*coef;
> > > > rs=sum(rs.^2);
> > > >
> > > > Where coef is a 4 element column vector
> > containing A,
> > > > B, C and D. This seems to work okay sometimes,
> > but of
> > > > course is very sensitive to the initial choices
> > of
> > > > the coefficients and I really don&#8217;t know
> > how
> > > > robust such an approach is. Does anyone have any
> > > > suggestions on a more suitable way to fit such a
> > > > function?
> > > >
> > > > Thanks, Dave
> > >
> > > By the way:
> > > For the function you are trying to minimize
> > > (A,B,C,D) = (0,0,0,0) is always a solution -
> > > and that's not what you want, I guess.
> > >
> > > Best wishes
> > > Torsten.
> >
> > Hi Torsten
> > Your right, (A,B,C,D) = (0,0,0,0) isn't what I want.
> > I tried the method you suggested and it works really
> > nicely. One issue appears when I artificially add
> > relatively small amounts of noise to the system (just
> > scaled normally distributed random numbers). Then the
> > fit can be a long way from the data, any suggestions?
> >
> > thanks for your help, Dave
>
> The estimated parameters should depend continuously
> on the input data.
> Maybe an error in your code ?
>
> Best wishes
> Torsten.

Hi Torsten,
I found the problem, I wasn't visualizing the result in a very sensible way. What I thought was mis-fit was simply the break between the two branches of the hyperbola. Do you have any ideas how I could constrain the fit so that only one branch is used to fit the data?
thanks again, Dave