bug-gsl
[Top][All Lists]
Advanced

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

[Bug-gsl] [GSL]: bug?


From: James W. Haefner
Subject: [Bug-gsl] [GSL]: bug?
Date: Wed, 03 Dec 2003 12:25:40 -0700
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030701

There seems to be a problem with the unweighted linear regression function. The following gives the wrong value for the slope. If I'm misusing it, please let me know.

--
James W. Haefner             Email: address@hidden
Dept Biology/Ecology Center  Voice: 435-797-3553
Utah State University        FAX:   435-797-1575
Logan, UT 84322-5305


=========================================================
/* tgsl_reg.c -- test GSL linear regression function */
/* header files */
#include <stdio.h>
#include <ctype.h>
#include <stdarg.h>
#include <string.h>
#include <math.h>

#include <gsl/gsl_errno.h>
#include <gsl/gsl_matrix.h>
#include <gsl/gsl_vector.h>
#include <gsl/gsl_odeiv.h>
#include <gsl/gsl_fit.h>


int main()
{
    int i;
    double c0,c1;  /* int and slope */
    double c00,c01,c11; /* var-covar elemnts for parameters*/
    double chisq;
    /* y = 2 + 10*x */
    double x[]={0,1,2,3,4,5,6};
    double y[]={2,12,22,32,42,52,62};
    i=gsl_fit_linear(x,(const size_t)1,y,(const size_t)1,(size_t)7,
            &c0,&c1,&c00,&c01,&c1,&chisq);
    printf(" c0=%f c1=%f  c00=%f c01=%f c00=%f chisq=%f\n",
            c0,c1,c00,c01,c11,chisq);
    return 0;
}





reply via email to

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