The code expectes a sample rate between 0.0 and 1.0. It then generates a random value and if it is smaller than the sampleRate the stat gets send. It's a probabilistic approach to sampling out values based on the assumption that you get uniformly distributed random values from Random.NextDouble()
.
This is done because if you have a lot of stats, you might not need to send every one. Sampling should give you a sufficiently good approximation then.