均匀分布的随机噪声的产生噪声、均匀

2023-09-11 07:17:46 作者:紅顏禍水丶

我一直在努力产生Perlin杂的map我的发电机。我碰到的问题是,该随机噪声不是正态分布,并且更可能的种正态分布。

I've been working on generating Perlin noise for a map generator of mine. The problem I've run into is that the random noise is not distributed normally, and is more likely a normal distribution of kinds.

由于两个整数X和Y,和种子值,我做到以下几点:

Given two integers X and Y, and a seed value, I do the following:

使用MurmurHash2以产生一个随机数(-1,1)。这是均匀分布的。 在插值立方插值整数值之间的点。现在值落在相似的价值观之间的范围内(-2.25,2.25),因为插补(在每个维度1.5)推断高点,且分布不再是均匀的。 在生成这些插入点,总结在一起,而减半的幅度(参见: Perling噪声的)作为总和的数目接近无穷大,该范围的上限现在接近previous值的两倍,或(-4.5,4.5),现在甚至不太均匀。 Use MurmurHash2 to generate a random number (-1,1). This is uniformly distributed. Interpolate points between integer values with cubic interpolation. Values now fall in the range (-2.25, 2.25) because the interpolation can extrapolate higher points (by 1.5 in every dimension) between similar values, and the distribution is no longer uniform. Generate these interpolated points, summing them together while halving the amplitudes (See: Perling noise) As the number of sums approaches infinity, the limit of the range now approaches twice the previous values, or (-4.5, 4.5) and is now even less uniform.

时,我想的范围为(-1,1),所以我把所有的最终值由4.5这显然是行不通的。其实,我(内各个维度,然后通过2相加后的噪声后1.5。)将它们沿途

This obviously doesn't work when I want a range from (-1, 1), so I divide all final values by 4.5. Actually, I divide them along the way (by 1.5 after interpolating each dimension, then by 2 after summing the noise.)

师后,我留下的(-1,1)的理论范围。但是,值绝大多数为(-0.2,0.2)。生成我的地图时,这并不能很好的工作,因为我需要确定填充地图的比例。本人也不能使用直方图来确定要使用的阈值,因为我生成随需应变的平方,而不是整个地图

After the division, I'm left with a theoretical range of (-1, 1). However, the vast majority of the values are (-0.2,0.2). This doesn't work well when generating my maps, since I need to determine the percentage of the map filled. I also cannot use histograms to determine what threshold to use, since I'm generating the squares on demand, and not the entire map.

我需要让我的均匀分布在两个点 - 插值后,和噪音功能求和之后。我不知道如何去这个,寿。

I need to make my distribution uniform at two points - after the interpolation, and after the summing of the noise functions. I'm not sure how to go about this, tho.

我的分布是这样的:

我需要它看起来是这样的:

I need it to look like this:

(两个图像来自维基百科。)

(Both images from Wikipedia.)

的任何解决方案AP preciated,但我正在写在C#中,因此code段将是非常有益的。的

推荐答案

结合所产生的样品与CDF为高斯,这是0.5 * ERF(X)+ 1(ERF =误差函数)。

Combine the resulting sample with the CDF for the gaussian, which is 0.5*erf(x) + 1 (erf = error function).

请注意,在凭借中心极限定理,只要你做的随机变量之和的,你得到高斯定律。

Note that in virtue of the Central Limit Theorem, whenever you make sums of random variables, you get gaussian laws.