func genIdxTable(name string, indexFunc func(int) (float64, uint)) {
	var (
		indent  int = 8
		columns int = 16
	)
	fmt.Printf("var %s = [256]uint8{\n", name)
	for i := 0; i < 256; i += columns {
		fmt.Printf("%*s//", indent, "")
		for j := 0; j < columns; j += 1 {
			fmt.Printf(" %4d", i+j)
		}
		fmt.Printf("\n")
		fmt.Printf("%*s//", indent, "")
		for j := 0; j < columns; j += 1 {
			log_x, _ := indexFunc(i + j)
			fmt.Printf(" %4.1f", log_x)
		}
		fmt.Printf("\n")
		fmt.Printf("%*s ", indent, "")
		for j := 0; j < columns; j += 1 {
			_, idx := indexFunc(i + j)
			fmt.Printf(" %3d,", idx)
		}
		fmt.Printf("\n")
		fmt.Printf("\n")
	}
	fmt.Printf("    }\n")
}
Generate go code for an array mapping the integers 0 .. 255 to an bucket
(index) in a bucketStats array.

indexFunc() is either our tweaked version of log2(x) or logRoot2(x) with
float64 being the actual value and int being the bucket index its mapped
to.
package bucketstats
import (
	"fmt"
	"math"
	"math/big"
)
func genLogRoot2Table() {
	logRoot2Index := func(val int) (logRoot2_x float64, idx uint) {
		logRoot2_x = math.Log(float64(val)) / math.Log(math.Sqrt(2))
		if logRoot2_x < 0 {
			idx = 0
		} else if logRoot2_x == 0 {
			idx = 1
		} else {
			idx = uint(math.Round(logRoot2_x))
		}
		return
	}
	genIdxTable("logRoot2RoundIdxTable", logRoot2Index)
	fmt.Printf("\n")
	genBucketTable("logRoot2RoundBucketTable", logRoot2Index, 128, 2)
	fmt.Printf("\n")
}
func genLog2Table() {
	log2Index := func(val int) (log2_x float64, idx uint) {
		log2_x = math.Log(float64(val)) / math.Log(2)
		if log2_x < 0 {
			idx = 0
		} else {
			idx = uint(math.Round(log2_x)) + 1
		}
		return
	}
	genIdxTable("log2RoundIdxTable", log2Index)
	fmt.Printf("\n")
	genBucketTable("log2RoundBucketTable", log2Index, 65, 1)
	fmt.Printf("\n")
}