Exemple #1
0
func frequencyTest(gen *Generator, d, iters int64) float64 {
	bins := make([]int64, d)
	for n := int64(0); n < iters; n++ {
		bins[gen.UniformInt(0, d-1)]++
	}

	probs := make([]float64, d)
	for i, _ := range probs {
		probs[i] = 1 / float64(d)
	}
	_, prob := rec.ChiSqr(bins, probs)
	return prob
}
Exemple #2
0
func serialTest(gen *Generator, d, iters int64) float64 {
	bins := make([]int64, d*d)
	for n := int64(0); n < iters; n++ {
		x, y := gen.UniformInt(0, d-1), gen.UniformInt(0, d-1)
		bins[y*d+x]++
	}

	probs := make([]float64, d*d)
	for i, _ := range probs {
		probs[i] = 1 / float64(d*d)
	}

	_, prob := rec.ChiSqr(bins, probs)
	return prob
}