This code works fine for me in the Julia 1.4.2 REPL after using Distributions. How did you run it when you got the error?
using Distributions