Two interesting probability problems

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.