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: Juan Pablo Carbajal
Subject: Re: Interpolating with f(x) = a*x^b, where b might be a non-integer?
Date: Sun, 28 Oct 2012 19:58:47 +0100

On Sun, Oct 28, 2012 at 7:50 PM, Olaf Till <address@hidden> 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.
>
> 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
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (GNU/Linux)
>
> iQIcBAEBCAAGBQJQjX6AAAoJEMDkvsXq/gWRxhcP/ilWmorTy4QZbmMbdO1GpNGT
> cRi5ooTmqrFUj6P3cAkNIMDD5ETZJcq586GkbzRUy4oM2RXWSfEnkigGrlh82bgU
> 2E4zp+0zkrSrRCHPqegPvnGkhiiucQmCzwCraB27Nr3lgegUjY9Erg83EirlI4NO
> l2Bg7cwFRWiEmBKIC/QJHeSdWDBcjg4gu43+i+yg00ZammGHA+CqHfEV2DARnOjM
> F7t8V14s2h/qcPLJ+bc4yqVwnvQ2fGiKYQzxnghKzXzOSbBqIJMC7FlcGDRvExko
> Po46kTQnifx+pM1mR4lffNhO0J4p6X4/inGnoJhgWjmER4yBkVhw7RZSUbC266UU
> AGvbqrjN4S3lmlzX4HMhH/1g4DE1dELZ5tOMqK9zpliPIWZeAePP+HQByC/I1f03
> DDEmPWy5C0gnW2evRLiNMc5A2TJnfXCMVjlbrw2KbJtokUlNc5YEgaXYh0T1I5uz
> CwATi9xZKoQOB+o0CuaJMMyn1w2XX8vZOaPPhNBFDqKaBaelQ2bFwdACA7gXH1Tc
> VO31vHCbbOqJq5lIPUh5UKpiAqdbPHxhM/0iwE6d6GU3dWrieVfrNxCP+40LoytT
> LX+uR0dWC3/SSd4Tlqk3RpQOY/UGx7SFh/2Vhg0YzKtktGYCZsuJpkhffG14b/eS
> RKARV/erwFVSbmst4zI+
> =fF+g
> -----END PGP SIGNATURE-----
>

Thanks Olaf for the correction, yes indeed I was thinking on (a*x)^b


reply via email to

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