help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Interpolating with f(x) = a*x^b, where b might be a non-integer?


From: Joanna Rutkowska
Subject: Re: Interpolating with f(x) = a*x^b, where b might be a non-integer?
Date: Wed, 31 Oct 2012 01:24:31 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121016 Thunderbird/16.0.1

On 10/28/12 19:50, Olaf Till wrote:
On Sun, Oct 28, 2012 at 03:43:32PM +0100, Juan Pablo Carbajal wrote:
>On Sun, Oct 28, 2012 at 3:35 PM, Joanna Rutkowska<address@hidden>  wrote:
> >Hello, given a set of measurements, I would like to find the best fitting
> >function of the form:
> >
> >f(x) = a*x^b, where a, b might be non integers. Here is a good example of
> >such a fitting:
> >
> >http://www.flybrushless.com/prop/view/38
> >
> >Is there any toolbox in octave that I could use to easily obtain the a and b
> >coefficients given a set of measurements?
> >
> >Thanks,
> >joanna.
> >_______________________________________________
> >Help-octave mailing list
> >address@hidden
> >https://mailman.cae.wisc.edu/listinfo/help-octave
>
>Hi,
>
>You can use the optim package[0] that includes curve fitting tools.
>Now, you should notice that taking log at both sides of your equality
>simplifies things a lot
>log f(x) = log (a*x^b) = b * log (a*x) = b*(log(a) + log(x)) =
>b*log(a) + b*log(x) = b*log(x) + C
>
>Where C is a new name for the product b*log(a). So if you fit the
>logarithms of measurements (scaling and shifting to avoid negative
>values!) you can even use the function polyfit or regress (from
>package statistics[1]).
You can linearize the problem (although the above contains some small
mistake, you surely see it yourself Juan Pablo, the correct must be
log(f(x))=log(a)+b*log(x)), but you must be aware that the fitting
result will then be (slightly?) different from fitting the original
(assuming a least sqare fit in both cases) since the dependents will
be transformed.

If you want to fit the original, you can use nonlin_curvefit from the
optim package, or leasqr if your packaged version does not yet contain
nonlin_curvefit.

Thanks Olaf! The nonlin_curevit works just great!

joanna.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]