noise-generator

is there any uniform smooth random function?


what i want is an uniform and smooth random function, that is bounded beetwen two values

the first candidate for smooth random function would be perlin noise, but its distribution is not uniform, as the image shows


perlin noise distribution




is there any uniform, smooth and clamped random function?


Solution

  • First, do you need continuous values with a uniform distribution? Or do you just need to divide the region into N equally likely intervals?

    If it's the latter, it's simple. Pre-generate a huge array (e.g. 0x10000000 in size) of noise evaluated at many random coordinates, sort the array, then divide the array into however many intervals you need. If you want to exploit the fact that noise's distribution is symmetric around zero, then for each value also add its sign flipped value to the array. The sorted value at the beginning of each interval is what you use in your boundary condition check.

    If you actually need the continuous range of values, then you can try to fit a function to uniformize the noise output. I propose one method for modifying noise distributions here and it was tried out here. This was used to make 4D noise have a similar distribution to 3D noise, but it should work to uniformize too. Note that the formula involves an integral of a polynomial to integer powers that vary depending on your tuning value, but you can manually write evaluation functions for a handful of these cases (probably won't need more than k=3), then write the lerp logic on top of those. Then you can either use a mathematical or manual+visual metric for determining the best tuning value.

    Obligatory noise algorithm selection note: Use good quality noise. That is, simplex-type noise with good gradient vector tables, or domain-rotated 3D+ Perlin. FastNoiseLite supports both (OpenSimplex2 or Perlin + SetRotationType3D(ImproveXYPlanes) + GetNoise(x, y, 0)). Take it with a grain of salt when tutorials recommend Perlin noise with no caveats. Perlin is an older noise algo that, without the domain-rotation technique, produces a lot of squareness that is an entirely unnecessary compromise for most applications.

    EDIT: Noticing that the domain in your image is 0 to 1. Most noise implementations, and indeed the library I linked, use the range -1 to 1. You can rescale after uniformization if you need to, though.