help-octave
[Top][All Lists]
Advanced

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

Re: Nonlinear fitting with lg(a+x)


From: Jaroslav Hajek
Subject: Re: Nonlinear fitting with lg(a+x)
Date: Fri, 13 Mar 2009 09:44:22 +0100

On Fri, Mar 13, 2009 at 9:20 AM, reposepuppy <address@hidden> wrote:
>
> Hello,
> I'm a college student who is attending a physical chemistry class now, and
> we're required to process the data obtained from experiments we've done to
> reach a plausible conclusion every week.
> This time, I've got 2 columns of data, and one of them is the concentration
> of a solution [c], the other the surface tension of the solution [r]; the
> task is to draw the curve representing the function of F(c,r)=0, and use it
> to draw the curve representing the function of F(c, dr/dc)=0 to reach some
> conclusion。I found out on the Internet that there is a function between them
> stated as :
>                             r=r0[1-a*lg(1+c/b)]
> where r0 is the surface tension when there is no solute in the solution, or
> in other words, c=0; it could be measured during the experiment. The
> constants a and b could be determined by making a nonlinear fitting using
> the data I've got.
> That's the question: I don't know how to transform this nonlinear function
> into a linear one; I could only make it (1-r/r0)=a*lg(b+c)-a*lg(b) and using
> the trial-and-error method(*See below) to find out what a and b are. But the
> error is too much for me(about 30% away from the theoretical one).
>
> Does anyone know how to solve this fitting problem using solely Octave?
> Thanks for help!
>

fsolve is now capable of solving over-determined nonlinear systems -
in other words, nonlinear fitting (with moderate residuals).

function r = model (r0, a, b, c)
  r = r0*(1 - a*log(1 + c/b));
endfunction

... get c, r

model_error = @(par) r - model (par(1), par(2), par(3), c);
par0 = [... initial guesses for r0, a, b]

par = fsolve (model_error, par0, ...options)

It will be available in 3.2, so your options are
1. wait for 3.2 release
2. compile development sources
3. send me your data and I can make the fit for you


> * The trial-and-error method I used is here, using Microsoft Excel (I could
> use Octave only to deal with some integration problem and linear
> fitting...):
> First, input the data into Excel and draw a XY scattered diagram, where
> X=(1-r/r0) and Y=lg(b+c). A linear distribution of dots would appear if the
> value of b was right.
> Second, calculate the R^2(the square of correlation coefficient) . It would
> be a value very close to 1 if the value of b was right.
> Third, change the b value until I can't make the R^2 higher. First try from
> 0 to 10, and find out the optimal value, and minimize the scale by 10 fold
> and try again... I tried from 0 to 2, and found out the R^2 will be the
> biggest when b was 0.6; and I tried from 0.50 to 0.70 and I found out it's
> 0.59~0.62(the R^2 will not change any more during this range).

These seem to be fairly good guesses. I think fsolve should not have
problems refining them.
For a more automatized method of obtaining initial guesses, you can
sample expected ranges of
parameters and pick the best match.

cheers

-- 
RNDr. Jaroslav Hajek
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz


reply via email to

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