Skip to content

Instantly share code, notes, and snippets.

@jdh30
Created November 21, 2022 22:30
Show Gist options
  • Save jdh30/af917fdf3af01e679581211d816a06f7 to your computer and use it in GitHub Desktop.
Save jdh30/af917fdf3af01e679581211d816a06f7 to your computer and use it in GitHub Desktop.
Simulating predator-prey dynamics
let g = 0.02 and k = 500 and t = 1500
let evolve(r, f) =
let dtrf = 0.0001 * r * f in
Some((r, f), (r + (1.0 - r/k)*r*g - dtrf, dtrf + (1.0 - g)*f))
let () =
Seq.unfold evolve (50, 10)
@ Seq.truncate 1500
@ Array.ofSeq
@ Chart.scatter "Predator-prey dynamics" "Rabbit population" "Fox population"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment