Package com.nr.ran

Examples of com.nr.ran.Ran


   

    // Test Indexx
    System.out.println("Testing Indexx");
    Ran myran = new Ran(17);
    for (i=0;i<N;i++) x[i]=myran.doub()
    Indexx idx =new Indexx(x);      // Create the index
    double[] xx=buildVector(x);     // Copy of x
    idx.sort(xx);     // Test sort on x itself
    for (i=0;i<N-1;i++) localflag = localflag || (xx[i] > xx[i+1]);
    globalflag = globalflag || localflag;
View Full Code Here


   

    // Test select
    System.out.println("Testing select");
    Ran myran = new Ran(17);
    for (i=0;i<N;i++) x[i]=myran.doub();
    for (i=0;i<M;i++) {
      k=myran.int32p() % N;
      xsel=Sorter.select(k,x);

      localflag = (x[k] != xsel);
      globalflag = globalflag || localflag;
      if (localflag) {
View Full Code Here

    // Generate the Markov sequence of states
    HMM.markovgen(atrans,state,0,17);

    // Generate the sequence of symbols emitted
    Ran myran=new Ran(17);
    for (i=0;i<N;i++) {
      r=myran.doub();
      sum=0.0;
      for (j=0;j<K;j++) {
        sum += b[state[i]][j];
        if (r < sum) {
          symbols[i]=j;
View Full Code Here

   

    // Test shell
    System.out.println("Testing shell");
    localflag=false;
    Ran myran = new Ran(17);
    for (i=0;i<N;i++) x[i]=myran.doub();
    Sorter.shell(x);
    for (i=0;i<N-1;i++) localflag = localflag || (x[i] > x[i+1]);
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** shell: Sorted values are not correctly ordered");
View Full Code Here

   

    // Test Heapselect
    System.out.println("Testing Heapselect");
    Heapselect heap = new Heapselect(M);
    Ran myran = new Ran(17);
    // Find top 100 values in 1000 random numbers
    for (i=0;i<N;i++) heap.add(myran.doub());
    for (i=0;i<M;i++) x[i]=heap.report(M-1-i);
    xm=x[0];    // The Mth largest

    Ran myran2 = new Ran(17); // Repeat same sequence
    j=0;
    for (i=0;i<N;i++) {
      val=myran2.doub();
      if (val >= xm) {
        if (j < M) y[j]=val;
        j++;
      }
    }
View Full Code Here

   

    // Test IQagent
    System.out.println("Testing IQagent");
    IQagent iq = new IQagent();
    Ran myran = new Ran(17);
    for (j=0;j<M;j++) {
      for (i=0;i<N;i++) iq.add(myran.doub());
    }

    // Percentiles for Ran
    sbeps=3.e-3;
    for (j=0;j<11;j++) {
View Full Code Here

   

    // Test selip
    System.out.println("Testing selip");
    Ran myran =new Ran(17);
    for (i=0;i<N;i++) x[i]=myran.doub();
    double[] xx=buildVector(x);   // Copy of array for later test
    for (i=0;i<M;i++) {
      k=myran.int32p() % N;
      xsel=Sorter.selip(k,x);

      // Test for position in array
      count=0;
      for (j=0;j<N;j++)
View Full Code Here

    }
//    for (i=0;i<N;i++) System.out.printf(x[i] << "  ";
//    System.out.printf(endl;

    // Calculate some function values and derivatives
    Ran myran=new Ran(14);
    Bessjy bess=new Bessjy();
    for (i=0;i<N;i++) {
      y=x[0]*(2.0*myran.doub()-1.0);
      Weights.weights(y,x,c);
      // Calculate function
      f=f1=f2=0;
      for (j=0;j<N;j++) {
        f += c[j][0]*bess.jn(5,x[j]);
 
View Full Code Here

    // Test laguer
    System.out.println("Testing laguer");
    // Roots of polynomial x^5+(1-i)x^4+(1+2i)x^3+(3+i)x^2+(2i)x+(2+i)"
    // Roots are x=i, x=-i, x=sqrt(2i), x=-i*sqrt(2i), x=(i-1)
    Ran myran =new Ran(17);
    for (i=0;i<N;i++) {
      x=new Complex(-2.0+4.0*myran.doub(),-2.0+4.0*myran.doub());
      x = laguer(aa,x,its);
      Complex r = a[4].add(x.mul(a[5]));
      r = a[3].add(x.mul(r));
      r = a[2].add(x.mul(r));
      r = a[1].add(x.mul(r));
View Full Code Here

   

    // Test Bracketmethod
    System.out.println("Testing Bracketmethod");

    Ran myran=new Ran(17);
    Bracketmethod br = new Bracketmethod();
    for (i=0;i<N;i++) {
      a=50.0*myran.doub();
      b=a+span;
      br.bracket(a,b,this);
//      System.out.printf(br.ax << " " << br.bx << " " << br.cx);
//      System.out.printf(br.fa << " " << br.fb << " " << br.fc << endl);
      localflag = localflag || (br.fa < br.fb) || (br.fc < br.fb);
    }
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** Bracketmethod: Faulty bracket center value not the smallest");
     
    }

    double sbeps=3.e-16;
    for (i=0;i<N;i++) {
      a=50.0*myran.doub();
      b=a+span;
      br.bracket(a,b,this);
      localflag = localflag || abs(br.fa - funk(br.ax))>sbeps
        || abs(br.fb - funk(br.bx))>sbeps
        || abs(br.fc - funk(br.cx))>sbeps;
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.