Skip to content

Instantly share code, notes, and snippets.

@kgadek
Created July 26, 2015 00:20
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 kgadek/d3d3b6c087ce607dc804 to your computer and use it in GitHub Desktop.
Save kgadek/d3d3b6c087ce607dc804 to your computer and use it in GitHub Desktop.
some weird gauss
import random
target_diffusion = 0.1
population=[[0,8,4], [2,7,2]]
pop_diffusion=[abs(0.1*max(x)) for x in zip(*population)]
individual=population[0]
while True:
rand_diffusion=[random.gauss(0, v) for v in diffusion]
if sum(rand_diffusion) != 0.0:
break # :)
individual_diffused = [random.gauss(x_val, v * target_diffusion * sum(individual) / sum(rand_diffusion)) for x_val, v in zip(individual, rand_diffusion)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment