Skip to content

Instantly share code, notes, and snippets.

@bmtgoncalves
Created September 11, 2016 16:12
Show Gist options
  • Save bmtgoncalves/3fcce41b89191d4da408def5bde36d9b to your computer and use it in GitHub Desktop.
Save bmtgoncalves/3fcce41b89191d4da408def5bde36d9b to your computer and use it in GitHub Desktop.
Bak_Sneppen model
def bak_sneppen(data, steps=10):
N = len(data)
for i in range(steps*N):
pos = np.argmin(data) # Find the position of the minimum value
# Replace the minimum valuea and both it's neighbours
data[(pos-1) % N] = np.random.random()
data[pos] = np.random.random()
data[(pos+1) % N] = np.random.random()
return data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment