Examples.QuasiMonteCarlo
Class GrayCodeCounter

java.lang.Object
  extended byExamples.QuasiMonteCarlo.GrayCodeCounter

public class GrayCodeCounter
extends java.lang.Object

Prints the grey codes gray(n), n=1,2,...,299 computed both directly and recursivley by changing (XORing with 1) the relevant bit. Done to see how irregularly the grey counter runs through the integers.

Recall that we use gray code counting to move through the integers in our implementations of low discrepancy sequences based on base b=2.


Constructor Summary
GrayCodeCounter()
           
 
Method Summary
static int gray(int n)
          The Gray code of n.
static void main(java.lang.String[] args)
           
static void printbin(int n)
          Print binary string representation of a positive integer n.
static int thebit(int n)
           
static int twopower(int j)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GrayCodeCounter

public GrayCodeCounter()
Method Detail

printbin

public static void printbin(int n)
Print binary string representation of a positive integer n. Most significant digit leftmost as usual.


thebit

public static int thebit(int n)

twopower

public static int twopower(int j)

gray

public static int gray(int n)
The Gray code of n.


main

public static void main(java.lang.String[] args)