本文介绍了生成范围 [0,x] 内的正态分布时间戳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我想生成一个文件,其中包含表示事件到达的时间戳(0 和绑定值 x 之间的整数,按递增顺序).事件到达率"应该是正态分布的",这意味着,在数据集的中间",到达率应该比开始和结束时更频繁.如何使用 java 生成这样的值列表?

I want to generate a file containing timestamps (integers between 0 and a bound value x, in increasing order) which represents arrivals of an event.The "Event arrival rate" should be "normal distributed" which means, somehow in the "middle" of the dataset the rate of arrivals should be more frequently as at the beginning and the end.How can i generate such a list of values using java?

问候

推荐答案

我同意 greedybuddha 的观点,即高斯函数是您在这里想要的,但您还表示您希望对您的事件进行排序 - Random.nextGaussian() 赢了不给你,它会给你正态分布的随机数.相反,使用高斯函数计算每个时间点的事件频率:

I agree with greedybuddha that a Gaussian function is what you want here, but you also stated that you want your events to be ordered - Random.nextGaussian() won't give you that, it will give you random numbers that are normally distributed. Instead, use the gaussian function to calculate the frequency of events at each point in time:

for (int t = 0; t < max; t++)
{
    f = Math.exp(-Math.pow(t - CENTER, 2.0) / (2.0 * Math.pow(WIDTH, 2.0)));
    for (int j = 0; j < f; j++)
    {
        writeEvent(t);
    }
}

CENTER 是您希望曲线峰值"所在的位置(可能是 max/2),而 WIDTH 是控制分布分布的参数.

CENTER is where you want the "peak" of the curve to be (probably max/2), and WIDTH is a parameter that controls the spread of the distribution.

这篇关于生成范围 [0,x] 内的正态分布时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-07 15:46