Skip to content

Commit 5c5a95d

Browse files
authored
Fix method name in RandomSampling.md (apple#18)
1 parent dd2ad89 commit 5c5a95d

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

Guides/RandomSampling.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ unstable implementation of `randomSample` explicitly shuffles the elements
9595
before returning them.
9696

9797
To see the bias without shuffling, consider the following example that uses a
98-
hypothetical `randomElementsUnshuffled` method. When selecting three out of
98+
hypothetical `randomSampleUnshuffled` method. When selecting three out of
9999
four elements from an array, whenever any of the first three elements are
100100
included in the result, they are always in their original positions. Elements
101101
selected after the initial `count` are in randomly selected positions.
@@ -104,19 +104,19 @@ selected after the initial `count` are in randomly selected positions.
104104
// This shows the behavior WITHOUT post-sample shuffling.
105105
// Selecting 3/4 elements, there are only four possible outcomes:
106106
let source = [10, 20, 30, 40]
107-
source.randomElementsUnshuffled(count: 3) // [10, 20, 30]
108-
source.randomElementsUnshuffled(count: 3) // [40, 20, 30]
109-
source.randomElementsUnshuffled(count: 3) // [10, 40, 30]
110-
source.randomElementsUnshuffled(count: 3) // [10, 20, 40]
107+
source.randomSampleUnshuffled(count: 3) // [10, 20, 30]
108+
source.randomSampleUnshuffled(count: 3) // [40, 20, 30]
109+
source.randomSampleUnshuffled(count: 3) // [10, 40, 30]
110+
source.randomSampleUnshuffled(count: 3) // [10, 20, 40]
111111
```
112112

113-
The proposed `randomElements` method has no positional bias:
113+
The proposed `randomSample` method has no positional bias:
114114

115115
```swift
116116
// The current behavior shuffles the elements, erasing the bias:
117117
let source = [10, 20, 30, 40]
118-
source.randomElements(count: 3) // [20, 30, 10]
119-
source.randomElements(count: 3) // [40, 20, 30]
118+
source.randomSample(count: 3) // [20, 30, 10]
119+
source.randomSample(count: 3) // [40, 20, 30]
120120
// ...several more possible outcomes
121121
```
122122

0 commit comments

Comments
 (0)