# Written in Julia 1.7.0 using Random, Distributions, BenchmarkTools # See docs: http://juliastats.org/Distributions.jl/stable/starting/ # set seed Random.seed!(123); # base Julia has rand() and randn() rand() # random [0, 1] randn() # random Normal(μ=0, σ=1) # sample from normal distribution @benchmark s = rand(Normal(5, 2), 10^6) @benchmark rand(TriangularDist(0, 5, 3), 10^6) d = Distributions.DiscreteNonParametric([0, 1, 2], [0.2, 0.7, 0.1]) @benchmark rand(d, 10^6)