我想通过添加随机性来创建看起来更像手绘线条的线条。我目前使用此公式来修改坐标
x-10+Math.floor(Math.random()*20)
这种随机分布是线性的,我想使用的东西更有可能击中目标。 X
根据看起来像的东西,但不一定是钟形曲线。怎么办呢?
答案 0 :(得分:1)
使用定义标准正态分布的概率密度函数:
function stdNormalDistribution (x) {
return Math.pow(Math.E,-Math.pow(x,2)/2)/Math.sqrt(2*Math.PI);
}
该函数在0附近对称,这意味着stdNormalDistribution(x) == stdNormalDistribution(-x).