[Gambas-user] curve fitting library ?

Wally wally at ...2037...
Mon Jan 23 12:29:43 CET 2012


Randall, Benoit

this example, using the spline stuff from the GSL is one of the most simple 
functions in GSL. All the intersting rest is much more confusing.

Have a look how easy fityk doing a peakfind on very noisy data:
(not sure the mailinglist allow me to attach screenshots )
honmepage: fityk.nieto.pl

On the other hand this fityk is not really free opensource i think.
 
But here is a code example of guessing gaussian peak from a 
clean exp function:
  
#include <iostream>
#include <cmath>

#include <fityk.h>

using namespace std;
using namespace fityk;

int main()
{
    Fityk *f = new Fityk;
    cout << f->get_info("version", true) << endl;
    cout << "ln(2) = " << f->calculate_expr("ln(2)") << endl;
    const double mu = 12.345;
    for (int i = 0; i != 500; ++i) {
        double x = i / 100. + 10;
        double y = ceil(100 * exp(-(x-mu)*(x-mu)/2));
        f->add_point(x, y, sqrt(y));
    }
    f->execute("Y = randnormal(y, s)");
    f->execute("guess %gauss = Gaussian");
    f->execute("fit");
    cout << "peak center: " << f->calculate_expr("%gauss.Center") << endl;
    delete f;
    return 0;
}

output:

Fityk 0.9.8
ln(2) = 0.693147
peak center: 12.3485

So ithink an implematation of GSL (or similar, maybe gnuplot))
would be great - but i'm not able to do it without help. 



On Monday, January 23, 2012 03:06:29 Randall Morgan wrote:
> You must be familiar with C at some level? I'd be surprised if the GSL
> doesn't already have a C wrapper somewhere. I haven't used it in many years
> so I can't recall, and I am sure it has changed. It sounds like you've
> already got a start. So you just need to invest more time into porting GSL
> to Gambas.
> 
> On Mon, Jan 23, 2012 at 2:59 AM, Wally <wally at ...2037...> wrote:
> > On Monday, January 23, 2012 11:47:47 Benoît Minisini wrote:
> > > Le 22/01/2012 09:54, Wally a écrit :
> > > > Does anyone have experience with curve fitting and/or
> > > > peakfinding
> > > > using gambas ?    (e.g. example code)
> > > > 
> > > > Is there a plain C library (Linux) known, suitable to this
> > > > problem
> > > > and gambas ?
> > > > 
> > > > Something like "fityk" (which is written in C++) but written in
> > > > plain C to use with "EXTERN"
> > > > 
> > > > I might wrap the fityk C++ or try Gnu Scientific Library, but
> > > > i'm still searching for alternatives.
> > > > 
> > > > wally
> > > 
> > > There is a GSLSpline example provided with Gambas. Does it help?
> > 
> > I did this example :)
> > 
> > 
> > 
> > 
> > ------------------------------------------------------------------------
> > ------ Try before you buy = See our experts in action!
> > The most comprehensive online learning library for Microsoft developers
> > is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> > Metro Style Apps, more. Free future releases when you subscribe now!
> > http://p.sf.net/sfu/learndevnow-dev2
> > _______________________________________________
> > Gambas-user mailing list
> > Gambas-user at lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/gambas-user
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fityk_snapshot_001.png
Type: image/png
Size: 107125 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20120123/8638089c/attachment.png>


More information about the User mailing list