问题:,如何从Julia中的高斯分布生成0,1区间内的随机数?
我认为朗是生成正态分布随机数的方法,但是文档中关于如何指定范围的描述非常不透明。
发布于 2018-11-21 04:06:48
使用分布包。如果你还没有的话:
using Pkg ; Pkg.add("Distributions")然后:
using Distributions
mu = 0 #The mean of the truncated Normal
sigma = 1 #The standard deviation of the truncated Normal
lb = 0 #The truncation lower bound
ub = 1 #The truncation upper bound
d = Truncated(Normal(mu, sigma), lb, ub) #Construct the distribution type
x = rand(d, 100) #Simulate 100 obs from the truncated Normal或者是一条线:
x = rand(Truncated(Normal(0, 1), 0, 1), 100)https://stackoverflow.com/questions/53404705
复制相似问题