Generate random samples using various sampling methods
Each member of the population has an equal probability of being selected. This is the most basic form of random sampling.
Use case: When the population is homogeneous and you want every member to have an equal chance of selection.
Example: Selecting 100 random customers from a database of 10,000 customers.
Select every kth element from the population after a random starting point. The interval k is calculated as: k = population_size / sample_size.
Use case: When you have an ordered list and want to ensure even coverage across the entire population.
Example: Selecting every 10th person from a list of 1,000 people to get a sample of 100.
Divide the population into homogeneous subgroups (strata) and randomly sample from each stratum proportionally.
Use case: When the population has distinct subgroups and you want to ensure each subgroup is adequately represented.
Example: Sampling from different age groups, ensuring each age group is represented proportionally in the sample.
Using a random seed allows you to reproduce the same sample. This is useful for:
Note: The same seed with the same parameters will always produce the same sample.