import java.util.Scanner; class MCBase2 { //********************************************************************** // * // Set up Halton sequences by putting in the base * // * //********************************************************************** static Halton halx=new Halton(2); static Halton haly=new Halton(3); public static void main(String[] args) { Scanner sc=new Scanner(System.in); //********************************************************************** // * // Get the number of histories desired * // * //********************************************************************** while(true) { int n=0; System.out.println("\n N?"); int ntry=sc.nextInt(); if(ntry < 0)System.exit(0); if(ntry >0)n=ntry; //********************************************************************** // * // Initialize the two bins we will be collecting information in. * // * //********************************************************************** double total_score=0.; double total_squared=0.; //********************************************************************** // * // For each history: * // * //********************************************************************** for(int ihistory=0;ihistory %2$10.5e +/- %3$10.5e (%4$6.3f percent)\n", n,xhat,mean_sd,mean_sd/xhat*100.); System.out.printf(" Standard deviation of process ==> %1$10.5e",sample_sd); } } static class Halton { public int base; int count=0; double previous=0.; Halton(int base0) { base=base0; } double next() { count++; int j=count; double frac=1./base; double ret=0.; while(j != 0) { int idigit=j - (j/base)*base; ret+=idigit*frac; j=(j-idigit)/base; frac/=base; } return ret; } } static double getScore() { //********************************************************************** // * // double x=Math.random(); * // * //********************************************************************** double x=halx.next(); double y=haly.next(); return x+y; } }