-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Closed
Labels
randomnessRandom number generation and the Random stdlibRandom number generation and the Random stdlib
Description
Minimal working example (Tested on Julia 1.5 and 1.6.)
julia> A = rand(Float32, 2^20);
julia> length(A)-length(unique(A))
Expected behavior
The expected number of duplicates when drawing n
times at random from a set of N
elements with replacement is equal to (see e.g. Proposition 4.1 in this paper)
expected_number_of_duplicates(N, n) = n - N * (1 - (1 - 1/N)^n)
For drawing a uniform Float32
, we therefore expect
julia> expected_number_of_duplicates(2^32, 2^20)
127.98946189880371
Actual behavior
I obtain numbers that are on the order of 60000
.
Metadata
Metadata
Assignees
Labels
randomnessRandom number generation and the Random stdlibRandom number generation and the Random stdlib