returns a -by- vector of values sampled uniformly at random, without replacement, from the integers 1 to .
returns a vector of values sampled uniformly at random, without replacement, from the values in the vector . The orientation of (row or column) is the same as .
or returns a sample taken with replacement if is , or without replacement if is . The default is .
or returns a weighted sample taken with replacement, using a vector of positive weights , whose length is . The probability that the integer is selected for an entry of is . Usually, is a vector of probabilities. does not support weighted sampling without replacement.
uses the stream for random number generation. is a member of the class. Default is the MATLAB® default random number stream.
Generate a random sequence of the characters , , , and , with replacement, according to the specified probabilities.
To randomly sample data, with or without replacement, use .
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Usage notes and limitations:
When sampling without replacement, the order of the output values might not match MATLAB.
Introduced before R2006a
When researchers need to select a representative sample from a larger population, they often utilize a method known as random selection. In this selection process, each member of a group stands an equal chance of being chosen as a participant in the study.
Random Selection vs Random Assignment
How does random selection differ from a random assignment? Random selection refers to how the sample is drawn from the population as a whole, while random assignment refers to how the participants are then assigned to either the experimental or control groups.
It is possible to have both random selection and random assignment in an experiment. Imagine that you use random selection to draw 500 people from a population to participate in your study. You then use random assignment to assign 250 of your participants to a control group (the group that does not receive the treatment or independent variable) and you assign 250 of the participants to the experimental group (the group that receives the treatment or independent variable).
Why do researchers utilize random selection? The purpose is to increase the generalizability of the results. By drawing a random sample from a larger population, the goal is that the sample will be representative of the larger group and less likely to be subject to bias.
What You Should Know About Random Selection in Research
Imagine that a researcher is selecting people to participate in a study. In order to pick participants, they might choose people using a technique that is the statistical equivalent of a coin toss.
They might begin by using random selection to pick geographic regions from which to draw participants. They might then use the same selection process to pick cities, neighborhoods, households, age ranges, and individual participants.
Another important thing to remember is that larger samples tend to be more representative, because even random selection can lead to a biased or limited sample if the sample size is small.
When the sample size is small, an unusual participant can have an undue influence over the sample as a whole. Using a much larger sample size tends to dilute the effects of unusual participants from skewing the results.
Elmes, DG, Kantowitz, BH, & Roediger, H L. Research Methods in Psychology. Belmont, CA: Wadsworth; 2012.
Hockenbury, D. H. & Hockenbury, S. E. (2007). Discovering Psychology. New York: Worth Publishers.