C#中的分形Perlin噪声函数的均匀分布 [英] Uniform distribution from a fractal Perlin noise function in C#

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

问题描述

我的Perlin杂点函数(在0.75持久性下相加6个八度的3D单形)会生成一个double s的2D数组数组.

My Perlin noise function (which adds up 6 octaves of 3D simplex at 0.75 persistence) generates a 2D array array of doubles.

这些数字每个均归一化为[-1,1],均值为0.我将其固定以避免异常,我认为这是由于浮点精度问题引起的,但我相当确定我的缩放系数是在理想情况下足以将噪声输出限制在恰好此邻域.

These numbers each come out normalized to [-1, 1], with mean at 0. I clamp them to avoid exceptions, which I think are due to floating-point accuracy issues, but I am fairly sure my scaling factor is good enough for restricting the noise output to exactly this neighborhood in the ideal case.

无论如何,这就是所有细节.关键是,这是一个256 x 256的噪声数组:

Anyway, that's all details. The point is, here is a 256-by-256 array of noise:

具有正常拟合度的直方图如下所示:

The histogram with a normal fit looks like this:

Matlab的lillietest是一项应用Lilliefors检验以确定一组数字是否来自正态分布的函数.我的结果是重复地为1,这意味着这些数字不是正态分布的.

Matlab's lillietest is a function which applies the Lilliefors test to determine if a set of numbers comes from a normal distribution. My result was, repeatedly, 1, which means that these numbers are not normally distributed.

我想要一个函数f(x),这样,当将其应用于我的噪声函数的值列表时,结果将显示为均匀分布.

I would like a function f(x) such that, when applied to the list of values from my noise function, the results appear uniformly distributed.

我希望此功能可以在C#中实现,并且无需花费几分钟即可运行.

I would like this function to be implementable in C# and not take minutes to run.

再一次,数字的来源无关紧要(问题在于将一种分布转换为另一种分布,特别是将类似法线的分布转换为统一的分布).不过,我的噪声函数实现是基于 this .您可以在此处找到上面的值数组.

Once again, it shouldn't matter where the numbers come from (the question is about transforming one distribution into another, specifically a normal-like one to uniform). Nevertheless, my noise function implementation is based on this and this. You can find the above array of values here.

推荐答案

奇怪的是,我刚刚就您的问题写了一篇文章:

Oddly enough I just wrote an article on your very question:

http://ericlippert.com/2012/02/21/generating-random-non-uniform-data/

我在这里讨论了如何将均匀分布转换为其他分布,但是您当然可以使用类似的技术来转换其他分布.

There I discuss how to turn a uniform distribution into some other distribution, but of course you can use similar techniques to transform other distributions.

这篇关于C#中的分形Perlin噪声函数的均匀分布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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