Random distributions: normal vs. triangle

ljfa

New Member
Jul 29, 2019
2,761
-46
0
Hi guys

sometimes uniformly distributed random values such as generated by rand.nextDouble() don't cut it, one might want some values to be more common than others. Minecraft mostly uses uniform distributions, but sometimes it's not quite appropriate.
One solution would be to add or subtract two independent uniform random numbers. This results in triangle distributed numbers.
rand.nextDouble()-rand.nextDouble() gives a Triangle(-1, 0, 1) distributed value, with expected value 0 and variance 1/6. So they're fairly easy to compute.
In nature many values instead follow a normal ("gaussian") distribution, e.g. sizes of livings, length of appendages, blood pressures.
N(0, 1)-distributed values can be gotten from rand.nextGaussian(). This uses a slightly more complicated algorithm to create them from uniform distributed values.

I'm currently using nextGaussian() for the size of flower patches and for the length of debuffs.
How much does the triangle distribution differ from the normal distribution in practice? Would a player notice or care if one substitutes them? And how expensive is a call to nextGaussian()? Or are there other examples for distributions one could use?
Or is it silly to even care about distributions at all?

I'm currently learning stochastics and I'm kinda concerned about getting distribution, expected value and standard deviation right. That's why I ask.

Here's a graph of the probability density for the normal, triangle and uniform distribution. In all three cases the expected value is 0 and the variance 1. Notice how much the uniform distribution differs from the other two.
dist.png

PS: To create triangle distributed values with expected value 0 and variance 1 you have to multiply rand.nextDouble()-rand.nextDouble() by sqrt(6).
 
Last edited:

InfinityRaider

New Member
Jul 29, 2019
1,169
-1
1
I'd say a triangular distribution is a good approximation of the standard normal distribution, specifically for this application.
 

ljfa

New Member
Jul 29, 2019
2,761
-46
0
I wonder how impacting the limited range of the triangular distribution is. Very large values are (almost) impossible.
 

InfinityRaider

New Member
Jul 29, 2019
1,169
-1
1
They are impossible yes, but the amount of times a significantly larger number from a Gauss curve (compared to the triangular) occurs negligible imo.