I'm trying to code the extra-trees classifier algorithm proposed here but I'm stuck on the part where i have to select a threshold Ath at random according to a distribution N(µ,σ), where µ and σ are respectively the mean and standard deviation of the pixel values at a position (k,l).
all is implemented in Java, only this part is left.
Supposing that I've already calculated the mean and the standard deviation into two variables mean and stddev.
How can I generate a value according to this normal distribution ?
Best How To :
Looking at the javadocs I found this https://docs.oracle.com/javase/8/docs/api/java/util/Random.html#nextGaussian--
turns out the random number generator actually can implement many distributions. I'm not sure why they call it
Random.nextGaussian() as it has mean=0 and std-1, it even says in the docs its actually a normal distribution.
since you have a mean and std you may have to massage the output from the random generator. changing the mean is simple, just add your mean to the output. The std deviation is a bit more difficult. But it is just scaling the distribution.
so if your desired std=sigma you would multiply the output (BEFORE ADDING THE MEAN) by sigma.
Random gauss_generator = new Random();
Double mean = 3;
Double stddev = 2.3;
//I realize the parenthesis aren't needed, but I really want to stress
//that you do the stretching BEFORE the shifting