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.

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

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.

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: