Skip to content

Instantly share code, notes, and snippets.

@karatedog
Last active October 4, 2015 11:18
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 karatedog/2627355 to your computer and use it in GitHub Desktop.
Save karatedog/2627355 to your computer and use it in GitHub Desktop.
Logistic map enumerator in Ruby
# Enumerator based Logistic map, can be used as a PRNG as well.
def logistic_map(x0, r)
return Enumerator.new do |yielder|
number = x0.to_f
r = r.to_f
loop do
yielder.yield(number)
number = r * number * (1 - number)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment