Created
March 8, 2012 15:35
-
-
Save eidas/2001523 to your computer and use it in GitHub Desktop.
Pythonの乱数評価用
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
import random | |
random.seed() | |
def rand(y,randmax,n): | |
for i in range(randmax+1): | |
y[i] = 0 | |
for i in range(randmax*n+1): | |
r = random.randint(0,randmax) | |
y[r] += 1 | |
return y | |
def kai_square(y,randmax,n): | |
k=0 | |
for i in range(randmax+1): | |
k += float(pow(y[i]-n, 2))/float(n) | |
return k | |
y={} | |
y=rand(y,255,100) | |
kai=kai_square(y,255,100) | |
print kai |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment