bootstrapSample
Draws a bootstrap sample of n elements with replacement.
Bootstrap sampling randomly picks elements from the list, allowing the same element to be chosen multiple times. This is commonly used for estimating the sampling distribution of a statistic (bootstrap method).
Example:
listOf(1, 2, 3).bootstrapSample(5) // e.g. [2, 1, 3, 1, 2]Return
a list of n randomly drawn elements, potentially with duplicates.
Parameters
the number of elements to draw. Must be non-negative.
the random number generator. Defaults to Random.
Type Parameters
the type of elements.
Draws a bootstrap sample of n elements with replacement.
This is a convenience overload that accepts any Iterable. The collection is materialized to a list internally.
Return
a list of n randomly drawn elements, potentially with duplicates.
Parameters
the number of elements to draw. Must be non-negative.
the random number generator. Defaults to Random.
Type Parameters
the type of elements.