Recently, I switched from learning Racket to Chez Scheme. I wanted to try to repeat some of my previous Racket exercises in Chez Scheme, but quickly ran into a barrier when my first choice required drawing random variates from a normal distribution. I looked for existing Chez Scheme libraries but came up empty. I considered SRFI 27: Sources of Random Bits, which includes example code for generating random numbers from a normal distribution, and reached out for guidance.

One of the areas of expertise at Cramer Fish Sciences is watershed and habitat restoration. In the context of that work, we are often faced with estimating how much rearing habitat is needed to support a specified number of juvenile salmonids (or how many juvenile salmonids are supported by a specified amount of rearing habitat). Our typical approach for generating these estimates is to use the territory size-fork length relationship from Grant and Kramer (1990).

R makes it easy to generate random numbers from a wide variety of distributions with a consistent interface. For example, runif, rnorm, and rpois generate random numbers from uniform, normal, and Poisson distributions, respectively.
> x = runif(n = 1000, min = 4.6, max = 9.3) > min(x) [1] 4.60374 > max(x) [1] 9.288063 > > y = rnorm(n = 1000, mean = 81, sd = 9) > mean(y) [1] 81.

© 2018-2019 Travis Hinkelman · Powered by the Academic theme for Hugo.