Created
May 14, 2014 08:23
-
-
Save arvsrao/fdceb1ec794a8796a991 to your computer and use it in GitHub Desktop.
code for generating the empirical distribution of max-segment lengths
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
from random import uniform | |
from numpy import array | |
from math import pi | |
def MaxArc(N): | |
cuts = [ uniform(0, 2*pi) for x in range(N) ] | |
cuts.sort() | |
other = [x for x in cuts] | |
other.insert(0, other.pop()) | |
cuts[0]+=2*pi | |
out = zip(cuts, other) | |
lengths = [ abs(x-y) for x,y in out ] | |
lengths.sort() | |
return lengths.pop() | |
def harmonic(N): | |
data = array([ 1/float(x+1) for x in range(N)]) | |
return data.sum() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment