-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnist-sp-800-90b.xml
103 lines (93 loc) · 5.17 KB
/
nist-sp-800-90b.xml
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?xml version="1.0" encoding="UTF-8"?>
<standard-document xmlns="http://riboseinc.com/isoxml">
<bibdata type="standard">
<language>en</language>
<script>Latn</script>
<status>
<stage>published</stage>
</status>
<copyright>
<from>2019</from>
</copyright>
<ext>
<doctype>article</doctype>
</ext>
</bibdata>
<sections>
<requirement id="_a7afe5c7-6ca6-4a88-b7ee-1080e979a3a7"><title>Generic Structure for Permutation Testing</title><label>/iid-testing/permutation-test/</label><classification><tag>type</tag><value>pseudocode</value></classification><description><dl id="_41df4983-a0f9-48aa-a89d-13eac556b663">
<dt>Input</dt>
<dd>
<p id="_053858ba-2304-45a3-95b1-6c74ee090194">
<stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>S</mi><mo>=</mo><mrow><mo>(</mo><msub><mi>s</mi><mn>1</mn></msub><mi>,</mi><mo>…</mo><mi>,</mi><msub><mi>s</mi><mi>L</mi></msub><mo>)</mo></mrow></math></stem>
</p>
</dd>
<dt>Output</dt>
<dd>
<p id="_ec791697-6f8d-478d-b566-9955f00aabf7">Decision on the IID assumption</p>
</dd>
<dt>Steps</dt>
<dd>
<ol id="_8104a51c-248d-4265-94e8-8e11898b8a7b" type="arabic">
<li>
<p id="_108d7f64-acd8-436e-82ac-9c2261197b52">For each test <stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>i</mi></math></stem></p>
<ol id="_1ec5a0d5-c88b-4281-a4ee-e32f3c9eaf8a" type="alphabet">
<li>
<p id="_6529af01-9cc3-4f16-b8f3-01c3e98f4807">Assign the counters <stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><msub><mi>C</mi><mrow><mi>i</mi><mi>,</mi><mn>0</mn></mrow></msub></math></stem> and <stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><msub><mi>C</mi><mrow><mi>i</mi><mi>,</mi><mn>1</mn></mrow></msub></math></stem> to zero.</p>
</li>
<li>
<p id="_e630fb9e-27dd-45eb-9e36-99c636f79c72">Calculate the test statistic <stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><msub><mi>T</mi><mi>i</mi></msub></math></stem> on <stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>S</mi></math></stem>.</p>
</li>
</ol>
</li>
<li>
<p id="_06630723-bf64-46d6-a75e-bcdcf77159ca">For <stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>j</mi><mo>=</mo><mn>1</mn></math></stem> to 10 000</p>
<ol id="_47b15a11-7bd6-4931-9cea-83213802bb17" type="alphabet">
<li>
<p id="_bbf93f59-5d17-4eb2-b330-485b3d2578d8">Permute <stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>S</mi></math></stem> using the Fisher-Yates shuffle algorithm.</p>
</li>
<li>
<p id="_4610f958-4e47-40b3-a2c6-6bdc0523d326">For each test <stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>i</mi></math></stem></p>
<ol id="_4d2f2d98-a709-4a2f-94ed-fdaacbbf0b3c" type="roman">
<li>
<p id="_d2d28b1a-92b1-43d1-a572-2213b1a25e8d">Calculate the test statistic <stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>T</mi></math></stem> on the permuted data.</p>
</li>
<li>
<p id="_ba18e0a0-630d-4442-b8ff-dce8b31064d4">If (<stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>T</mi><mi>&</mi><mo>></mo><mi>;</mi><msub><mi>T</mi><mi>i</mi></msub></math></stem>), increment <stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><msub><mi>C</mi><mrow><mi>i</mi><mi>,</mi><mn>0</mn></mrow></msub></math></stem>. If (<stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>T</mi><mo>=</mo><msub><mi>T</mi><mi>i</mi></msub></math></stem>), increment <stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><msub><mi>C</mi><mrow><mi>i</mi><mi>,</mi><mn>1</mn></mrow></msub></math></stem>.</p>
</li>
</ol>
</li>
</ol>
</li>
<li>
<p id="_d7bec73c-80ab-42b0-9798-a3ede9fc880b">If ( (<stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><msub><mi>C</mi><mrow><mi>i</mi><mi>,</mi><mn>0</mn></mrow></msub><mo>+</mo><msub><mi>C</mi><mrow><mi>i</mi><mi>,</mi><mn>1</mn></mrow></msub><mi>&</mi><mo><</mo><mi>;</mi><mo>=</mo><mn>5</mn></math></stem>) or (<stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><msub><mi>C</mi><mrow><mi>i</mi><mi>,</mi><mn>0</mn></mrow></msub><mi>&</mi><mo>></mo><mi>;</mi><mo>=</mo><mn>9995</mn></math></stem>) ) for any <stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>i</mi></math></stem>, reject the IID assumption; else, assume that the noise source outputs are IID.</p>
</li>
</ol>
</dd>
</dl>
<sourcecode id="_f16ba12a-d015-4f35-8e4a-ef21e2949226">import FisherYatesShuffle, TestStatistic
DecideIID(S: ZZ[], L: RR) : Boolean =
for i <- 1 : L do
C[i, 0] <- 0, C[i, 1] <- 0
T[i] <- TestStatistic(S)
end
for j <- 1 : 10000 do
S' <- FisherYatesShuffle(S)
for i <- 1 : L do
T <- TestStatistic(S')
if T' > T'[i]
C[i, 0] <- C[i, 0] + 1
end
if T' == T[i]
C[i, 1] <- C[i, 1] + 1
end
end
end
for i <- 1 : L do
if (C[i, 0] + C[i, 1] <= 5) or (C[i, 0] >= 9995)
return false
end
end
return true</sourcecode>
</description></requirement>
</sections>
</standard-document>