Created
April 10, 2018 15:41
-
-
Save randombit/ed2f4cd9c3781cc40b43f5de277eade3 to your computer and use it in GitHub Desktop.
Miller-Rabin error probabilities
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
from math import log, pow, sqrt | |
import sys | |
# Estimate Miller-Rabin error probability based on bitsize (k) | |
# and number of MR tests (t) | |
# https://www.math.dartmouth.edu//~carlp/PDF/paper88.pdf | |
k = int(sys.argv[1]) | |
t = int(sys.argv[2]) | |
if t * 9 > k: | |
print("invalid k,t") | |
err = log(1 / (pow(k, 3.0/2) * pow(2,t) * pow(t, -.5) * pow(4, 2-sqrt(t*k)))) / log(2) | |
print("p(%d,%d) = %.02f" % (k, t, err)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You need to provide k and t as command line arguments