Sampling
Sampling is the process where by sample units are selected from a large population for analysis. The sample should be selected such that the results and inferences generated from them should be fairly applicable and can be generalized to the population from which it was initially sampled. There are a lot of ways in which sampling can be done. We will discuss them in the How to do it... section.
Getting ready
You have to have the StatsBase
package ready. This can be done by running using StatsBase
in the REPL.
How to do it...
- The simplest way of sampling is random sampling, where one can draw a random element from the array, which is the population. This kind of sampling is generally used for ensuring that selection bias does not happen. This kind of sampling can be done using the
sample()
function of theStatsBase
package:sample(x)
The output would look like the following:
- Now, as we have seen how to randomly sample an element from a population, we would now see...