Sample Data Sets with std::sample
Learn to sample data sets with std::sample.
We'll cover the following
The std::sample()
algorithm takes a random sample of a sequence of values and populates a destination container with the sample. It is useful for analyzing a larger set of data, where the random sample is taken to be representative of the whole.
A sample set allows us to approximate the characteristics of a large set of data, without analyzing the full set. This provides efficiency in exchange for accuracy, a fair trade-off in many circumstances.
How to do it
In this recipe, we'll use an array of
We'll start with a simple function to return a rounded
int
from adouble
. The standard library lacks such a function and we'll need it later:
Get hands-on with 1200+ tech skills courses.