Created
November 21, 2022 22:30
-
-
Save jdh30/af917fdf3af01e679581211d816a06f7 to your computer and use it in GitHub Desktop.
Simulating predator-prey dynamics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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