Java normal distribution

前端 未结 2 745
没有蜡笔的小新
没有蜡笔的小新 2020-12-13 00:01

I\'m trying to simulate the arrival of fans to a stadium. The system itself, I believe it won\'t be a problem, but, the arrival of the fans follows a normal distribution.

2条回答
  •  死守一世寂寞
    2020-12-13 00:46

    nextGaussian() will draw samples from a normal distribution with mean 0 and std-deviation 1, so if you want mean 1 hour and std-deviation 15 minutes you'll need to call it as nextGaussian()*15+60.

    From the docs for Random.nextGaussian():

    Returns:
    the next pseudorandom, Gaussian ("normally") distributed double value with mean 0.0 and standard deviation 1.0 from this random number generator's sequence

提交回复
热议问题