Package com.nr.ran

Examples of com.nr.ran.Ranhash


    average=N/(double)(M);
    double[] ebins = buildVector(M,average);

    // Check fingerprint of int32()
    localflag=false;
    Ranhash myran1 = new Ranhash();
    for (i=0;i<10;i++)
      localflag=localflag || (myran1.int32(i) != fingerprint1[i]);
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** Ranhash: int32() does not match fingerprint");
     
    }

    // Check statistics
    for (i=0;i<M;i++) bins[i]=0.0;
    for (i=0;i<N;i++) bins[myran1.int32p(i+10000)%M] += 1.0;
    chsone(bins,ebins,dfW,chisqW,probW);df = dfW.val; chisq = chisqW.val; prob = probW.val;
    System.out.printf("     chisq,int32(): %f  prob: %f\n",chisq, prob);

    localflag = (prob < 0.05);
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** Ranhash: int32() does not give distribution with correct variance");
     
    }

    // Check fingerprint of int64()
    localflag=false;
    Ranhash myran2 = new Ranhash();
    for (i=0;i<10;i++)
      localflag=localflag || (myran2.int64(i) != fingerprint2[i]);
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** Ranhash: int64() does not match fingerprint");
     
    }

    // Check statistics
    for (i=0;i<M;i++) bins[i]=0;
    for (i=0;i<N;i++) bins[(int)(myran2.int64p(i)%M)] += 1;
    chsone(bins,ebins,dfW,chisqW,probW);df = dfW.val; chisq = chisqW.val; prob = probW.val;
    System.out.printf("     chisq,int32(): %f  prob: %f\n",chisq, prob);
    localflag = (prob < 0.05);
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** Ranhash: int64() does not give distribution with correct variance");
     
    }

    // Check fingerprint of doub()
    Ranhash myran3 = new Ranhash();
    localflag=false;
    for (i=0;i<10;i++)
      localflag=localflag || abs(myran3.doub(i)-fingerprint3[i])>sbeps;
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** Ranhash: doub() does not match fingerprint");
     
    }

    // Check statistics
    for (i=0;i<M;i++) bins[i]=0;
    for (i=0;i<N;i++) bins[(int)(floor(M*myran3.doub(i)))] += 1;
    chsone(bins,ebins,dfW,chisqW,probW);df = dfW.val; chisq = chisqW.val; prob = probW.val;
    System.out.printf("     chisq,int32(): %f  prob: %f\n",chisq, prob);
    localflag = (prob < 0.05);
    globalflag = globalflag || localflag;
    if (localflag) {
View Full Code Here

TOP

Related Classes of com.nr.ran.Ranhash

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.