Data Science, Computer Science, Python, Probability, Machine Learning.
This should mimic the Pythonic semantics of random.choice, i.e. it doesn’t care about the type of elements stored in the input array. We also pass the pointer to a random number generator (rng) object that we’ll use for sampling. I’ve picked up this style of defining random functions (compared to