Sampling is a pretty intuitive concept. To explain it, I’ll flashback to 10-year-old me, drunk and in a back alley casino.
I lean over the roulette wheel, clutching my head as I see my life savings taken away. How did it come to this? I’ve rolled a 00 three out of the ten times I’ve rolled this wheel of my life, where there are a total of 37 notches. I’m unable to leave, desperately clinging on to ten years of my savings fitted into the chip rack.
I try distracting myself with numbers. What the probability of rolling my three 00’s? Well there should be a chance of a , and so chance of not rolling it. Multiplying by the permutations gave me an unlikely result of .
My mood worsened. I should never have emptied my entire piggy bank into chips. Am I doomed to waste my life at the ripe age of 10?
No! I will not simply take this as a lesson about gambling. My purpose is noble, and my heart is true. Luck cannot be so out of my favor. After half of the people leave, drudgingly, with empty pockets, followed by the other half which ripped their pockets from their tear-soaked hands, I slither my way back to the roulette table. With not even the managers left, I set my notebook on the rim of the wheel. Pulling out a synthetic ivory ball from my pocket, I spin the wheel 200 times, recording the results.
I wrote down 5 times 00 was rolled, 97 times green was rolled, and 98 times red was rolled. Now I did some arithmetic expecting a rigged game and daydreaming about a very angry complaint to the Washington State Gambling Commission. , , .
\@\\#
The point still stands though. Sampling takes the values of a random variable and generalizes to describe the random variable as a whole. Where in our case the random variable was the final notch our ball rolls on.
This might sound light right? WRONG! What if we want to sample a really disgusting random variable which has a probability density function of :
Remember, when we sample, we want to compile a list of values of (which are the values on the x-axis) with a frequency that matches the density function.
Hmmm, this is difficult. To sample, as always, we’ll have to go back to playing games. Consider creating a dart board behind this distribution, which has a length , and a height :
Now let’s situate ourselves with a few hundred darts standing before the board. Due to how intoxicated we are, every throw lands at a uniformly random location on the rectangle. Like the monkeys we are, we begin throwing. Every time it lands above the distribution the dart bounces off and we try again. If it lands under the distribution the dart stays there. At the end we write down the x value of all the darts. Now notice that a part with a thicker distribution has a proportionally higher chance of being sampled than a thinner part, so thus we sampled the graph!
Ok, now you might be looking for some real-world examples since you’ve only heard one about a drunk ten-year-old hitting up the casino (which is pretty relatable). One that comes to mind is that people often prefer discreet models (ie. histograms) to continuous ones. To do this, we can sample the density function a lot of times and create a histogram at intervals of values with a height based on the number of times was sampled in that interval.
Enjoy the darts!... and statistics too!