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: Olaf Till
Subject: Re: Interpolating with f(x) = a*x^b, where b might be a non-integer?
Date: Sun, 28 Oct 2012 19:50:40 +0100
User-agent: Mutt/1.5.20 (2009-06-14)

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.

Olaf

> [0] http://octave.sourceforge.net/optim/index.html
> [1] http://octave.sourceforge.net/statistics/index.html
> 
> Cheers
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://mailman.cae.wisc.edu/listinfo/help-octave

-- 
public key id EAFE0591, e.g. on x-hkp://pool.sks-keyservers.net

Attachment: signature.asc
Description: Digital signature


reply via email to

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