Skip to content

Instantly share code, notes, and snippets.

@arvsrao
Created May 14, 2014 08:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arvsrao/fdceb1ec794a8796a991 to your computer and use it in GitHub Desktop.
Save arvsrao/fdceb1ec794a8796a991 to your computer and use it in GitHub Desktop.
code for generating the empirical distribution of max-segment lengths
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