Skip to content

Instantly share code, notes, and snippets.

@corollari
Last active April 2, 2020 09:32
Show Gist options
  • Save corollari/1785ec07fa00ce3e558e51d2157886e1 to your computer and use it in GitHub Desktop.
Save corollari/1785ec07fa00ce3e558e51d2157886e1 to your computer and use it in GitHub Desktop.
Simulation of a Hall-Irwin distribution applied on Z_p
from random import randint
import matplotlib.pyplot as plt
P = 29
ITERATIONS = 100000
SUMNUMS = 100
a = [0]*P
for k in range(ITERATIONS):
b = sum([randint(0,P) for i in range(SUMNUMS)])%P
a[b]+=1
plt.bar(range(P), a)
plt.show()

While the simulation graph seems to indicate that a sum of 100 random numbers over Z_29 has a uniform distribution, I don't see any specific reason that would lead me to believe that this is actually true, especially for any prime field and any number of summands.

This could be proved or refuted by taking the probability distribution given in theorem 2.1 of this paper and checking that \sum^{n-1}_{i=0} P(i*p + j) is the same \forall j in {0, ... ,p-1} where n is the number of summands and p is the prime that defines the field. Note that the k used in the definition of P would need to be replaced by p-1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment