Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions sp800_22_non_overlapping_template_matching_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ def non_overlapping_template_matching_test(bits):
W.append(count)

mu = float(M-m+1)/float(2**m) # Compute mu and sigma
sigma = M * ((1.0/float(2**m))-(float((2*m)-1)/float(2**(2*m))))
variance = M * ((1.0/float(2**m))-(float((2*m)-1)/float(2**(2*m))))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the documentation, the original sigma was actually variance


chisq = 0.0 # Compute Chi-Square
for j in range(N):
chisq += ((W[j] - mu)**2)/(sigma**2)
chisq += ((W[j] - mu)**2)/(variance)

p = gammaincc(N/2.0, chisq/2.0) # Compute P value
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to change here, the original author code is inherently correct


Expand Down