Should use `rand.nextDouble()` instead of `rand.nextDouble` because it changes the internal state of `rand`.