均匀分布的随机噪声的产生 [英] Generation of uniformly distributed random noise

查看:1783
本文介绍了均匀分布的随机噪声的产生的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在努力产生Perlin杂的<一个href="http://stackoverflow.com/questions/3129676/whats-a-good-way-to-generate-random-clusters-and-paths/3131010#3131010">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:

  • 使用<一个href="http://stackoverflow.com/questions/3134759/how-can-i-best-generate-a-static-array-of-random-number-on-demand/3135446#3135446">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.

这篇关于均匀分布的随机噪声的产生的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆