Package com.nr.ran

Examples of com.nr.ran.Ran.doub()


    // Test values against those of rf(x,y,z);
    Ran myran = new Ran(17);
   
    for (i=0;i<N;i++) {
      x=10.0*myran.doub();
      y=10.0*myran.doub();

      f1[i]=rc(x,y);
      f2[i]=rf(x,y,y);
    }
    System.out.printf("rc: Maximum discrepancy = %f\n", maxel(vecsub(f1,f2)));
View Full Code Here


    // inverse of Pks agrees with Pks
    Ran myran = new Ran(17);
    localflag=false;
    sbeps=6.e-10// XXX 5.e-10 not pass
    for (i=0;i<10;i++) {
      z=0.3+3.0*myran.doub();
      a=norm.pks(z);
      b=norm.invpks(a);
//      if (abs(z-b) > sbeps) {
//        System.out.printf(setprecision(15) << z << " %f\n", b << " %f\n", abs(z-b));
//      }
View Full Code Here

    // inverse of Qks agrees with Qks
    localflag=false;
    sbeps=5.e-10;
    for (i=0;i<1000;i++) {
      z=0.3+3.0*myran.doub();
      a=norm.qks(z);
      b=norm.invqks(a);
//      if (abs(z-b) > sbeps) {
//        System.out.printf(setprecision(15) << z << " %f\n", b << " %f\n", abs(z-b));
//      }
View Full Code Here

    // Test Krig (and Powvargram)
    System.out.println("Testing Krig (and Powvargram)");
    Ran myran = new Ran(17);
    double[][] pt = new double[M][2];
    for (i=0;i<M;i++) {
      pt[i][0]=(double)(N)*myran.doub();
      pt[i][1]=(double)(N)*myran.doub();
      actual[i]=cos(pt[i][0]/20.0)*cos(pt[i][1]/20.0);
    }
    for (i=0;i<N;i++) {
      for (j=0;j<N;j++) {
View Full Code Here

    System.out.println("Testing Krig (and Powvargram)");
    Ran myran = new Ran(17);
    double[][] pt = new double[M][2];
    for (i=0;i<M;i++) {
      pt[i][0]=(double)(N)*myran.doub();
      pt[i][1]=(double)(N)*myran.doub();
      actual[i]=cos(pt[i][0]/20.0)*cos(pt[i][1]/20.0);
    }
    for (i=0;i<N;i++) {
      for (j=0;j<N;j++) {
        k=N*i+j;
 
View Full Code Here

    Gammadist normc = new Gammadist(alpha,beta);
    Ran myran = new Ran(17);
    sbeps=5.0e-14;
    localflag=false;
    for (i=0;i<1000;i++) {
      u=3.0*myran.doub();
      a=normc.cdf(u);
      b=normc.invcdf(a);
//      if (abs(u-b) > sbeps) {
//        System.out.printf(setprecision(15) << u << " %f\n", b << " %f\n", abs(u-b));
//      }
View Full Code Here

    // Test RBF_interp
    Ran myran = new Ran(17);
    double[][] pt = new double[M][2];
    for (i=0;i<M;i++) {
      pt[i][0]=(double)(N)*myran.doub();
      pt[i][1]=(double)(N)*myran.doub();
      actual[i]=cos(pt[i][0]/20.0)*cos(pt[i][1]/20.0);
    }
    for (i=0;i<N;i++) {
      for (j=0;j<N;j++) {
View Full Code Here

    // Test RBF_interp
    Ran myran = new Ran(17);
    double[][] pt = new double[M][2];
    for (i=0;i<M;i++) {
      pt[i][0]=(double)(N)*myran.doub();
      pt[i][1]=(double)(N)*myran.doub();
      actual[i]=cos(pt[i][0]/20.0)*cos(pt[i][1]/20.0);
    }
    for (i=0;i<N;i++) {
      for (j=0;j<N;j++) {
        k=N*i+j;
 
View Full Code Here

      y[i]=1.0+x[i]*(1.0+x[i]*(1.0+x[i]*(1.0+x[i])));
    }
    Ran myran = new Ran(17);
    Poly_interp z = new Poly_interp(x,y,3);
    for (i=0;i<N;i++) {
      xx[i]=myran.doub();
      yy[i]=z.interp(xx[i]);    // interpolated values
      dyy[i]=z.dy;        // Estimated errors
      zz[i]=1.0+xx[i]*(1.0+xx[i]*(1.0+xx[i]*(1.0+xx[i])))// Actual Values
    }
    System.out.printf("     Poly_interp: Max. estimated error: %f\n", maxel(dyy));
View Full Code Here

    // Test Shep_interp
    System.out.println("Testing Shep_interp");
    Ran myran = new Ran(17);
    double[][] pt = new double[M][2];
    for (i=0;i<M;i++) {
      pt[i][0]=(double)(N)*myran.doub();
      pt[i][1]=(double)(N)*myran.doub();
      actual[i]=cos(pt[i][0]/20.0)*cos(pt[i][1]/20.0);
    }
    for (i=0;i<N;i++) {
      for (j=0;j<N;j++) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.