Package com.nr.fi

Examples of com.nr.fi.Midpnt


    // integral of distribution is one
    sbeps=1.e-8;
    df=100.;
    func_Chisqdist dist = new func_Chisqdist(df);
    Midpnt q2=new Midpnt(dist,0.0,4.0);
    Midinf q3=new Midinf(dist,4.0,1.0e99);
    integral=qromo(q2)+qromo(q3);
    localflag = abs(1.0-integral) > sbeps;
//    System.out.printf(setprecision(15) << 1.0-integral);
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** Chisqdist: Distribution is not normalized to 1.0");
     
    }

    // cdf agrees with incomplete integral
    sbeps=1.e-7;
    df=100.;
    func_Chisqdist dist2 = new func_Chisqdist(df);
    Chisqdist normcdf=new Chisqdist(df);
    localflag=false;

    for (i=0;i<N;i++) {
      q2=new Midpnt(dist2,0.0,x[i]);
      integral=qromo(q2);
      c[i]=integral;
      d[i]=normcdf.cdf(x[i]);
//      System.out.printf(c[i]-d[i]);
      localflag = localflag || abs(c[i]-d[i]) > sbeps;
View Full Code Here


    // integral of distribution is one
    sbeps=5.e-8;
    m=0.5; s=1.5;
    func_Lognormaldist dist= new func_Lognormaldist(m,s);
    Midpnt q2 = new Midpnt(dist,0.0,10.0);
    Midinf q3 = new Midinf(dist,10.0,1.0e99);
    integral=qromo(q2)+qromo(q3);
    localflag = abs(1.0-integral) > sbeps;
//    System.out.printf(setprecision(15) << 1.0-integral);
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** Lognormaldist: Distribution is not normalized to 1.0");
     
    }

    // cdf agrees with incomplete integral
    sbeps=2.e-7;
    m=0.5; s=1.5;
    func_Lognormaldist dist2= new func_Lognormaldist(m,s);
    Lognormaldist normcdf = new Lognormaldist(m,s);
    localflag=false;
    for (i=0;i<N;i++) {
      q2 = new Midpnt(dist2,0.0,x[i]);
      integral=qromo(q2);
      c[i]=integral;
      d[i]=normcdf.cdf(x[i]);
//      System.out.printf(c[i]-d[i]);
      localflag = localflag || abs(c[i]-d[i]) > sbeps;
View Full Code Here

    // integral of distribution is one
    sbeps=1.e-8;
    m=1.0;s=2.0;
    func_Cauchydist dist=new func_Cauchydist(m,s);
    Midinf q1 = new Midinf(dist,-1.0e99,-1.0);
    Midpnt q2 = new Midpnt(dist,-1.0,1.0);
    Midinf q3 = new Midinf(dist,1.0,1.0e99);
    integral=qromo(q1)+qromo(q2)+qromo(q3);
    localflag = abs(1.0-integral) > sbeps;
//    System.out.printf(setprecision(15) << 1.0-integral);
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** Cauchydist: Distribution is not normalized to 1.0");
     
    }

    // cdf agrees with incomplete integral
    sbeps=1.e-7;
    m=0.5;s=1.5;
    func_Cauchydist dist2=new func_Cauchydist(m,s);
    Cauchydist normcdf = new Cauchydist(m,s);
    localflag=false;
    for (i=0;i<N;i++) {
      if (x[i] < 0.0) {
        q1 = new Midinf(dist2,-1.e99,x[i]);
        integral=qromo(q1);
      } else {
        q1 = new Midinf(dist2,-1.e99,-1.0);
        q2 = new Midpnt(dist2,-1.0,x[i]);
        integral=qromo(q1)+qromo(q2);
      }
      c[i]=integral;
      d[i]=normcdf.cdf(x[i]);
//      System.out.printf(c[i]-d[i]);
View Full Code Here

    // integral of distribution is one
    sbeps=1.e-8;
    beta=1.5;
    func_Expondist dist =new func_Expondist(beta);
    Midpnt q2 = new Midpnt(dist,0.0,4.0);
    Midinf q3 = new Midinf(dist,4.0,1.0e99);
    integral=qromo(q2)+qromo(q3);
    localflag = abs(1.0-integral) > sbeps;
//    System.out.printf(setprecision(15) << 1.0-integral);
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** Expondist: Distribution is not normalized to 1.0");
     
    }

    // cdf agrees with incomplete integral
    sbeps=1.e-7;
    beta=1.5;
    func_Expondist dist2 = new func_Expondist(beta);
    Expondist normcdf=new Expondist(beta);
    localflag=false;
    for (i=0;i<N;i++) {
      q2 = new Midpnt(dist2,0.0,x[i]);
      integral=qromo(q2);
      c[i]=integral;
      d[i]=normcdf.cdf(x[i]);
//      System.out.printf(c[i]-d[i]);
      localflag = localflag || abs(c[i]-d[i]) > sbeps;
View Full Code Here

    // integral of distribution is one
    sbeps=1.e-8;
    m=1.0;s=2.0;
    func_Logisticdist dist = new func_Logisticdist(m,s);
    Midinf q1 = new Midinf(dist,-1.0e99,-1.0);
    Midpnt q2 = new Midpnt(dist,-1.0,1.0);
    Midinf q3 = new Midinf(dist,1.0,1.0e99);
    integral=qromo(q1)+qromo(q2)+qromo(q3);
    localflag = abs(1.0-integral) > sbeps;
//    System.out.printf(setprecision(15) << 1.0-integral);
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** Logisticdist: Distribution is not normalized to 1.0");
     
    }

    // cdf agrees with incomplete integral
    sbeps=1.e-7;
    m=0.5;s=1.5;
    func_Logisticdist dist2 = new func_Logisticdist(m,s);
    Logisticdist normcdf = new Logisticdist(m,s);
    localflag=false;
    for (i=0;i<N;i++) {
      if (x[i] < 0.0) {
        q1 = new Midinf(dist2,-1.e99,x[i]);
        integral=qromo(q1);
      } else {
        q1 = new Midinf(dist2,-1.e99,-1.0);
        q2 = new Midpnt(dist2,-1.0,x[i]);
        integral=qromo(q1)+qromo(q2);
      }
      c[i]=integral;
      d[i]=normcdf.cdf(x[i]);
//      System.out.printf(c[i]-d[i]);
View Full Code Here

    // integral of distribution is one
    sbeps=2.e-6;
    alpha=2.5; beta=1.5;
    func_Betadist dist = new func_Betadist(alpha,beta);
    Midpnt q2 = new Midpnt(dist,0.0,1.0);
    integral=qromo(q2);
    localflag = abs(1.0-integral) > sbeps;
//    System.out.printf(setprecision(15) << 1.0-integral);
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** Betadist: Distribution is not normalized to 1.0");
     
    }

    // cdf agrees with incomplete integral
    sbeps=5.e-6;
    alpha=2.5; beta=1.5;
    func_Betadist dist2 = new func_Betadist(alpha,beta);
    Betadist normcdf =new Betadist(alpha,beta);
    localflag=false;
    for (i=0;i<N;i++) {
      Midpnt qq2 = new Midpnt(dist2,0.0,x[i]);
      integral=qromo(qq2);
      c[i]=integral;
      d[i]=normcdf.cdf(x[i]);
//      System.out.printf(c[i]-d[i]);
      localflag = localflag || abs(c[i]-d[i]) > sbeps;
View Full Code Here

    // integral of distribution is one
    sbeps=5.e-7;
    nu1=5.0; nu2=5.0;
    func_Fdist dist = new func_Fdist(nu1,nu2);
    Midpnt q2 = new Midpnt(dist,0.0,10.0);
    Midinf q3 = new Midinf(dist,10.0,1.0e99);
    integral=qromo(q2)+qromo(q3);
    localflag = abs(1.0-integral) > sbeps;
//    System.out.printf(setprecision(15) << 1.0-integral);
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** Fdist: Distribution is not normalized to 1.0");
     
    }

    // cdf agrees with incomplete integral
    sbeps=1.e-6;
    nu1=5.0; nu2=5.0;
    func_Fdist dist2 = new func_Fdist(nu1,nu2);
    Fdist normcdf=new Fdist(nu1,nu2);
    localflag=false;
    for (i=0;i<N;i++) {
      q2 = new Midpnt(dist2,0.0,x[i]);
      integral=qromo(q2);
      c[i]=integral;
      d[i]=normcdf.cdf(x[i]);
//      System.out.printf(c[i]-d[i]);
      localflag = localflag || abs(c[i]-d[i]) > sbeps;
View Full Code Here

//    a=0.0;
//    b=1.0;
    a=0.0;
    b=PI;
    func_midpnt func_midpnt = new func_midpnt();
    Midpnt mpt = new Midpnt(func_midpnt,a,b);

    for (j=0;j<M;j++) {
      s=mpt.next();
//      System.out.printf(setw(6) << j << setw(24) << s << endl;
    }

    expect=fint_midpnt(b)-fint_midpnt(a);
//    System.out.printf(setw(9) << expect << endl;
View Full Code Here

    // integral of distribution is one
    sbeps=2.e-7;
    alpha=2.5; beta=1.5;
    func_Gammadist dist = new func_Gammadist(alpha,beta);
    Midpnt q2 = new Midpnt(dist,0.0,2.0);
    Midinf q3 = new Midinf(dist,2.0,1.0e99);
    integral=qromo(q2)+qromo(q3);
    localflag = abs(1.0-integral) > sbeps;
//    System.out.printf(setprecision(15) << 1.0-integral);
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** Gammadist: Distribution is not normalized to 1.0");
     
    }

    // cdf agrees with incomplete integral
    sbeps=5.e-7;
    alpha=2.5; beta=1.5;
    func_Gammadist dist2 = new func_Gammadist(alpha,beta);
    Gammadist normcdf = new Gammadist(alpha,beta);
    localflag=false;
    for (i=0;i<N;i++) {
      q2 =new Midpnt(dist2,0.0,x[i]);
      integral=qromo(q2);
      c[i]=integral;
      d[i]=normcdf.cdf(x[i]);
//      System.out.printf(c[i]-d[i]);
      localflag = localflag || abs(c[i]-d[i]) > sbeps;
View Full Code Here

    // integral of distribution is one
    sbeps=1.e-10;
    n=2.0;m=1.0;s=2.0;
    func_Studenttdist dist = new func_Studenttdist(n,m,s);
    Midinf q1 = new Midinf(dist,-1.0e99,-1.0);
    Midpnt q2 = new Midpnt(dist,-1.0,1.0);
    Midinf q3 = new Midinf(dist,1.0,1.0e99);
    integral=qromo(q1)+qromo(q2)+qromo(q3);
    localflag = abs(1.0-integral) > sbeps;
//    System.out.printf(setprecision(15) << 1.0-integral);
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** Studenttdist: Distribution is not normalized to 1.0");
     
    }

    // cdf agrees with incomplete integral
    sbeps=1.e-8;
    n=2.0;m=0.5;s=1.5;
    func_Studenttdist dist2 = new func_Studenttdist(n,m,s);
    Studenttdist normcdf = new Studenttdist(n,m,s);
    localflag=false;
    for (i=0;i<N;i++) {
      if (x[i] < 0.0) {
        q1 = new Midinf(dist2,-1.e99,x[i]);
        integral=qromo(q1);
      } else {
        q1 = new Midinf(dist2,-1.e99,-1.0);
        q2 = new Midpnt(dist2,-1.0,x[i]);
        integral=qromo(q1)+qromo(q2);
      }
      c[i]=integral;
      d[i]=normcdf.cdf(x[i]);
//      System.out.printf(c[i] << " %f\n", d[i] << " %f\n", c[i]-d[i]);
      localflag = localflag || abs(c[i]-d[i]) > sbeps;
    }
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** Studenttdist: cdf does not agree with result of quadrature");
     
    }

    // inverse cdf agrees with cdf
    n=2.0;m=0.5;s=1.5;
    Studenttdist normc = new Studenttdist(n,m,s);
    Ran myran = new Ran(17);
    sbeps=1.0e-13;
    localflag=false;
    for (i=0;i<1000;i++) {
      u=m-3.0*s+6.0*s*myran.doub();
      a=normc.cdf(u);
      b=normc.invcdf(a);
//      System.out.printf(setprecision(15) << u << " %f\n", b << " %f\n", abs(u-b));
      localflag = localflag || abs(u-b) > sbeps;
    }
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** Studenttdist: Inverse cdf does not accurately invert the cdf");
     
    }

    // Function aa() agrees with incomplete integral
    sbeps=1.e-7;
    n=2.0;m=0.0;s=1.0;
    func_Studenttdist dist3 = new func_Studenttdist(n,m,s);
    Studenttdist normaa = new Studenttdist(n,m,s);
    localflag=false;
    for (i=0;i<10;i++) {
      u = 0.5*i;
      Midpnt qq1 = new Midpnt(dist3,-u,u);
      c[i]=qromo(qq1);
      d[i]=normaa.aa(u);
//      System.out.printf(setprecision(6) << c[i] << " %f\n", d[i] << " %f\n", c[i]-d[i]);
      localflag = localflag || abs(c[i]-d[i]) > sbeps;
    }
View Full Code Here

TOP

Related Classes of com.nr.fi.Midpnt

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.