Package com.nr.ran

Examples of com.nr.ran.Ran


    }
   
    // inverse cdf agrees with cdf
    m=0.5;s=1.5;
    Normaldist normc = new Normaldist(m,s);
    Ran myran = new Ran(17);
    sbeps=5.0e-14;
    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;
    }
View Full Code Here


    ranvec(a);
    ranvec(b);
    b=vecadd(b,u);
    ranvec(c);
    ranvec(r);
    Ran myran = new Ran(17);
    alpha=myran.doub();
    beta=myran.doub();

   

    // Test cyclic
    System.out.println("Testing cyclic");
View Full Code Here

    }

    // inverse cdf agrees with cdf
    beta=1.5;
    Expondist normc=new Expondist(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 NRsparseCol
    System.out.println("Testing NRsparseCol");
    Ran myran = new Ran(17);
    double[] a =new double[N];
   
    // XXX java not support unsigned int.
    for (i=0;i<nnvals;i++) a[myran.int32p() % N] = (double)(i);
    nnvals=0;   // There may be fewer than nnvals non-zero elements
    for (i=0;i<N;i++)
      if (a[i] != 0.0) nnvals++;
    NRsparseCol as = new NRsparseCol(N,nnvals);
    k=0;
View Full Code Here

   

    // Test NRsparseMat
    System.out.println("Testing NRsparseMat");
    Ran myran = new Ran(17);
    double[][] a = new double[N][M];
    nvals=N+M;
   
    // XXX java not support unsigned int.
    for (i=0;i<nvals;i++) a[myran.int32p() % N][myran.int32p() % M] = (double)(i);
    nvals=0;    // There may be fewer than nvals non-zero elements
    for (i=0;i<N;i++)
      for(j=0;j<M;j++)
        if (a[i][j] != 0.0) nvals++;
    NRsparseMat as = new NRsparseMat(N,M,nvals);
View Full Code Here

    }

    // inverse cdf agrees with cdf
    m=0.5;s=1.5;
    Logisticdist normc = new Logisticdist(m,s);
    Ran myran = new Ran(17);
    sbeps=5.0e-14;
    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);
//      if (abs(u-b) > sbeps) {
//        System.out.printf(setprecision(15) << u << " %f\n", b << " %f\n", abs(u-b));
//      }
View Full Code Here

   

    // Test ADAT
    System.out.println("Testing ADAT (and NRsparseMat)");
    Ran myran = new Ran(17);
    nvals=N+M;    // Create a sparse matrix with random non-zero entries
    for (i=0;i<nvals;i++) a[myran.int32p() % N][myran.int32p() % M] = (double)(i);
    nvals=0;    // There may be fewer than nvals non-zero elements
    for (i=0;i<N;i++)
      for(j=0;j<M;j++)
        if (a[i][j] != 0) nvals++;
View Full Code Here

    }

    // inverse cdf agrees with cdf
    alpha=2.5; beta=1.5;
    Betadist normc = new Betadist(alpha,beta);
    Ran myran = new Ran(17);
    sbeps=5.0e-14;
    localflag=false;
    for (i=0;i<1000;i++) {
      u=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 invxlogx
    System.out.println("Testing invxlogx");

    Ran myran = new Ran(17);
    for (i=0;i<N;i++) {
      y1 = -exp(-1.0)*myran.doub();
//      System.out.printf(setprecision(17) << y1;
      x=invxlogx(y1);
      y2=x*log(x);
//      System.out.println(" %f\n", x << " %f\n", y2);

View Full Code Here

    }

    // inverse cdf agrees with cdf
    nu1=5.0; nu2=5.0;
    Fdist normc=new Fdist(nu1,nu2);
    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

TOP

Related Classes of com.nr.ran.Ran

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.