1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//! Statistical helpers shared by the integration test suite.
/// Compute the chi-squared statistic for a byte buffer against the
/// uniform distribution over 256 buckets.
///
/// Returns the raw chi-squared value (sum of `(observed-expected)^2 /
/// expected` over all 256 buckets). For 255 degrees of freedom the
/// upper-tail critical value at α = 0.001 is approximately 330.
/// Approximate Wald–Wolfowitz runs statistic on a byte buffer,
/// categorising each byte as 0 or 1 by comparison with the median
/// value 0x80.
///
/// Returns the standardised z-score. |z| > 6 implies a stream far
/// from chance — typically a stuck or biased source.