First consider question 1:
From the natural number 1,2....N choose m not to repeat the number, which is the maximum expected?
Assuming that the maximum value of a single test is K, then
P (k) =c (k−1m−1) C (MN)
E (Max) =∑K=MNP (k) K=∑K=MNMC (MK) C (MN)
Because ∑K=MNC (MK) =c (m+1n+1)
E (Max) =MC (m+1n+1) C (MN) =m (n+1)/(m+1)
First give the Python code to simulate the validation:
def simulation_notrepeat (n,m):
tot_average = 0 for
i in range (10000):
max = 0
count = 0
is_repeated = Set ([]) while
count < m:
x = Random.randint (1,n)
if x to is_repeated:
is_repeated.add (x)
Count + = 1
if x > Max:
max = x
tot_average + max
print (tot_average/10000)
def test_ Notrepeat (n,m):
print (m* (n+1)/(m+1))
Question 2: Assuming that question 1 all numbers can be duplicated, then the maximum number of expectations.
Suppose the maximum value of a single test is K
P (k) =km− (k−1) MNM
E (Max) =∑K=1NP (k) k
The specific closed expression I did not solve, there are solutions, please inform the ^_^.
Also using Python validation:
Import Random
def Simulation (n,m):
tot_average = 0 for
i in range (10000):
max = 0 for
j in Range (m):
x = Random.randint (1,n)
if x > Max:
max = x
tot_average = max
print (tot_average/10000)
def Test_math (n,m):
average = 0 for
k in range (1,n+1):
average = = (K**m-((k-1) **m)) *k
print (average/( N**M))
def test_notrepeat (n,m):
print (m* (n+1)/(m+1)
def Test (N,m,simulation,test_math):
Simulation (N,M)
Test_math (n,m)
test (100,35,simulation,test_math)
test (100,35,simulation_notrepeat,test_ Notrepeat)
Results:
Expect to see a repeat of the relative repetition of a larger, but very close.