//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& // BINARY REBLOCKING BUFFER. YLL, based on NDD. JAVA VERSION 2005/05/07. // THIS IS A NON-STATIC, OBJECT-ORIENTED VERSION. // // To compile: javac brbdemo.java or "m brbdemo" // To run: java brbdemo //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& import java.io.*; import java.util.Random; //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& // BINARY REBLOCKING BUFFER. YLL, based on NDD. JAVA VERSION 2005/05/07. //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& class brb_buffer { int Lmax,N; double a[],b[]; double brb_mean,brb_err; // used for returning values FileOutputStream fout;// DEBUUGGING PrintStream pout; //HACK (REMOVE IN REAL VESRIN) //========== CONSTRUCTOR: ALLOCATE BUFFER Lmax LEVELS DEEP ============== brb_buffer(final int Lmax) { this.Lmax = Lmax; N = 0; a = new double[Lmax+1]; b = new double[Lmax+1]; int l; for (l=0; l<=Lmax; l++) b[l] = 0.0d; // no need to init a try { fout = new FileOutputStream ("brb.out"); pout = new PrintStream (fout); } catch (Exception e) {}; } //========== APPEND DATA xx AND UPDATE MULTIHEAP public void append (double xx) { int l,ivar; double yy; ivar = N; yy = xx; l = 0; for (;;) { b[l] += yy*yy; if ((ivar & 1) == 0) {a[l] = yy; break;} else {yy += a[l]; ivar>>=1; l++;} } N++; } //========== REPORT MEAN AND STDEV in mean and err public void report () { int l,S,M,Lmax_actual,key; double SoB,VoBM,VoMoBM; double[] aEoMoBM,aEoEoMoBM; boolean flag_warning; aEoMoBM = new double[Lmax+1]; aEoEoMoBM = new double[Lmax+1]; if (N<=1) {brb_mean = brb_err = -999.0d; return;} System.out.println ("brb_report with N="+N); //----- Find the level of the largest heap, Lmax_actual. Lmax_actual=-1; // blah for (l=0; l<=Lmax; l++) { if ( (N & (1<=0; l--) { if ( (N & (1<