Consider the construction of a string of characters which is C characters in length, by randomly selecting from an N-character alphabet (selecting randomly
with replacement).
If the probability that all characters are distinct equals the probability that exactly one character appears twice but all the other characters appear just once, then what is the number of characters in the alphabet?
Find N in terms of C.
The probability that all are different is
C(n,c)*c! / n^c
The probability that there's exactly one duplicate is
n*C(n-1,c-2)*c!/2 / n^c
leads to
warning('off', 'all')
for n=3:99
for c=3:n
diff= nchoosek(n,c)*factorial(c) / n^c;
oneDup= n*nchoosek(n-1,c-2)*factorial(c)/2 / n^c;
if diff==oneDup
disp([c,n])
end
end
% fprintf('\n')
end
showing
C N
3 5
4 9
5 14
6 20
7 27
8 35
9 44
10 54
11 65
12 77
13 90
which follows N = (C^2 + C) / 2 - 1
|
Posted by Charlie
on 2025-04-05 12:20:10 |