# Why is sampling useful in machine learning?

I have met that question online and I wanted to know where sampling can simulate complex processes and why?

Why is sampling useful in machine learning?

1. Sampling can increase the accuracy of the model
2. Sampling can simulate complex processes
3. Sampling is lower cost
4. Sampling can save lots of time

I can select multiple ones. As far as I know, sampling is lower cost and can save lots of time but, can it simulate complex processes?

TL:DR - If you know the posterior distribution of the complex process (i.e. the output distribution), and that distribution is one which can be modelled with reasonable accuracy, then sampling from it should reasonably represent the responses of the complex system.

An example could be a complex decision process, whereby many decisions are made consecutively, maybe with some conditional or temporal relationships along the way (basically any process that is considered to be complex). Now imagine, after all this complexity, there are e.g. two possible categorically outputs: a zero or a one. Well this something we might be able to model with a Bernoulli distribution, assuming we can estimate a reasonable parameter $p$ (specific to the Bernoulli distribution).

By sampling from the distribution, we would hope to draw samples, which are representative of the complex process. I hope this covers your main question. I think point 4. is also clear to understand as well from my trivial example. I am unsure as to what cost refers exactly in point 3.

As for point 1., there are examples where (random) sampling, for example in a grid search of model/optimisation parameters can improve results, as it results in an improved exploration of the parameter space compared to other methods such as grid-search.

• I don't quite agree on Point #1 - I see grid search as a particular type of sampling, much like random selection. I'm interpreting "sampling" as "using only a subset of possible samples/cases/parameters/etc", in which case sampling wouldn't improve the performance of the model - you'd always be better off using the full sample set/parameter space/etc. Commented Jul 31, 2018 at 20:54
• I agree that random sampling is comparable to grid search (hence why I explicitly put random in parentheses). I think you are right that a full run over the parameter space would beat e.g. random sampling, however I am assuming real-world constraints, in that it is often implausible to actually try all permutations. In the case of a continuous parameter space, a full sample is actually impossible on our discrete precision machines :-) Commented Jul 31, 2018 at 21:36

sampling is useful in machine learning because sampling, when designed well, can provide an accurate, low variance approximation of some expectation (eg expected reward for a particular policy in the case of reinforcement learning or expected loss for a particular neural net in the case of supervised learning) with relatively few samples.

in some cases - eg learning starcraft - it is unfeasible to evaluate all possible trajectories for a given policy model and, as such, it is impossible to compute the expected value even for a single model (and this is for a single point in parameter space!). in these cases, sampling is the only feasible approach.