Package com.nr.model

Examples of com.nr.model.Fitmrq


        y[i] += a[j]*exp(-SQR((x[i]-a[j+1])/a[j+2]));
      y[i] *= (1.0+SPREAD*ndev.dev());
      sig[i]=SPREAD*y[i];
    }
    FGauss fgauss = new FGauss();
    Fitmrq myfit=new Fitmrq(x,y,sig,guess,fgauss);
    myfit.fit();

//    System.out.printf(setw(18) << "chi-squared:%f\n", setw(13) << myfit.chisq);
//    System.out.printf(fixed << setprecision(6);
//    for (i=0;i<MA;i++) System.out.printf(setw(9) << myfit.a[i];
//    System.out.printf(endl;
//    System.out.println("Uncertainties:");
//    for (i=0;i<MA;i++) System.out.printf(setw(9) << sqrt(myfit.covar[i][i]);
//    System.out.printf(endl;
//    System.out.println("Expected results:");
//    for (i=0;i<MA;i++) System.out.printf(setw(9) << a[i];
//    System.out.printf(endl);

    for (j=0;j<MA;j++) {
      localflag = abs(myfit.a[j]-a[j]) > 2.0*sqrt(myfit.covar[j][j]);
      globalflag = globalflag || localflag;
      if (localflag) {
        fail("*** Fitmrq: Fitted parameters not within estimated uncertainty");
       
      }
    }

    // Test the hold() method on parameters 1 and 4
    myfit.hold(1,2.0);
    myfit.hold(4,5.0);
    myfit.fit();

//    System.out.printf(setw(18) << "chi-squared:%f\n", setw(13) << myfit.chisq);
//    for (i=0;i<MA;i++) System.out.printf(setw(9) << myfit.a[i];
//    System.out.printf(endl;
//    System.out.println("Uncertainties:");
//    for (i=0;i<MA;i++) System.out.printf(setw(9) << sqrt(myfit.covar[i][i]);
//    System.out.printf(endl;
//    System.out.println("Expected results:");
//    for (i=0;i<MA;i++) System.out.printf(setw(9) << a[i];
//    System.out.printf(endl);

    localflag = (myfit.a[1] != a[1]);
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** Fitmrq: A held parameter does not have its assigned value");
     
    }

    localflag = (myfit.a[4] != a[4]);
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** Fitmrq: A held parameter does not have its assigned value");
     
    }

    localflag = (myfit.covar[1][1] != 0.0);
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** Fitmrq: A held parameter does not have uncertainty=0.0");
     
    }

    localflag = (myfit.covar[4][4] != 0.0);
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** Fitmrq: A held parameter does not have uncertainty=0.0");
     
    }

    for (j=0;j<MA;j++) {
      localflag = abs(myfit.a[j]-a[j]) > 2.0*sqrt(myfit.covar[j][j]);
      globalflag = globalflag || localflag;
      if (localflag) {
        fail("*** Fitmrq: Fitted parameters (with 2 parameters held) not within estimated uncertainty");
       
      }
    }

    localflag=false;
    for (i=0;i<MA;i++) {
      for (j=0;j<MA;j++) {
        if (i==1 || i==4 || j==1 || j==4)
          localflag = localflag || myfit.covar[i][j] != 0.0;
        else
          localflag = localflag || myfit.covar[i][j] == 0.0;
      }
    }
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** Fitmrq: Covariance matrix with 2 held parameters has incorrect pattern");
     
    }

    // Test the free() method
    myfit.free(1);
    myfit.fit();

//    System.out.printf(setw(18) << "chi-squared:%f\n", setw(13) << myfit.chisq);
//    for (i=0;i<MA;i++) System.out.printf(setw(9) << myfit.a[i];
//    System.out.printf(endl;
//    System.out.println("Uncertainties:");
View Full Code Here

TOP

Related Classes of com.nr.model.Fitmrq

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.