Verify distribution uniformity/Naive: Difference between revisions
Verify distribution uniformity/Naive (view source)
Revision as of 01:40, 6 December 2011
, 12 years ago→{{header|Go}}: library changes
Thundergnat (talk | contribs) (→{{header|Perl 6}}: Add Perl 6 example) |
m (→{{header|Go}}: library changes) |
||
Line 288:
"fmt"
"math"
"math/rand"
"time"
)
Line 317 ⟶ 318:
// parameter "delta."
func distCheck(f func() int, n int,
repeats int, delta float64) (max float64, flatEnough bool) {
count := make([]int, n)
for i := 0; i < repeats; i++ {
Line 324 ⟶ 325:
expected := float64(repeats) / float64(n)
for _, c := range count {
max = math.
}
return max, max < delta
Line 330 ⟶ 331:
// Driver, produces output satisfying both tasks.
func main() {
rand.Seed(time.Now().UnixNano())
const calls = 1000000
max, flatEnough := distCheck(dice7, 7, calls, 500)
Line 344 ⟶ 341:
Output:
<pre>
Max delta:
Max delta:
</pre>
|