[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-gsl] Linear fitting
From: |
Francisco M Neto |
Subject: |
Re: [Help-gsl] Linear fitting |
Date: |
Thu, 03 May 2018 19:47:36 +0200 |
Patrick,
Thanks a lot! I really should have paid more attention to how I
handled those indices. I've adapted my code to incorporate your
suggestions and it's working now.
Cheers,
Francisco
On Thu, 2018-05-03 at 10:47 -0600, Patrick Alken wrote:
> Francisco,
>
> You have some errors in the way you handle your 2D arrays. I have
> made a small modification to define new 1D arrays (x and y) and store
> your fit data into those arrays. The program output now says:
>
> Performing fit with 20 points...done! (status = 0)
> ====== BET results ======
> y = 0.000022 + 0.005321 x
> [2.54531e-11, -1.26944e-10
> -1.26944e-10, 8.07463e-10]
> Chi Square = 0.000000
> =========================
>
> My changes are attached - you can find the lines I changed with the
> "PA"
> keyword
>
> On 05/03/2018 04:13 AM, Francisco M Neto wrote:
> > Greetings!
> >
> > I have been trying to use gsl for some linear least squares
> > fitting, but for some reason I'm getting bad results.
> >
> > Instead of returning the results of the fit, gsl_fit_linear()
> > returns -nan for all parameters. I'm not sure if I'm passing
> > something
> > wrong to it, but I do know that there is no problem with the data
> > (I've
> > ran it through other LS fitting procedures and results are
> > consistent).
> >
> > Attached are the source and an example data file. I've compiled
> > and ran with:
> >
> > $ gcc -I/usr/include/gsl/ -lm -lgsl -lgslcblas -o teste_bet
> > teste_bet.c
> >
> > $ ./teste_bet data.dat
> >
>
>
--
--
[]'s,
Francisco M Neto
Institut für Anorganische Chemie
Universität Duisburg-Essen