3 ms·
function generate_candidates(;n=1) return 100 .+ (15 .* randn(n, 1)) end How does this yield a Gaussian distribution?
by CamperBob2 5y ago
function generate_candidates(;n=1)
return 100 .+ (15 .* randn(n, 1))
end
How does this yield a Gaussian distribution?
- mattkrause 5y ago`randn` returns draws from a standard normal distribution (i.e., a Gaussian with mean 0 and standard deviation 1); the n is for normal. It's then stretched to have an SD of 15 via multiplication, and shifted to have a mean of 100. This is Julia, but it's the same in Matlab and Numpy (np.random.randn); it'd be rnorm in R (which also lets you specify the mean and sd directly).
- CamperBob2 5y agoAh, thanks, I was reading it as "random number."