Probability: What is the probability that sum of elements in array is greater than or equal to 10?

534 Views Asked by At

I want to calculate probability such that the sum of N array elements is greater than or equal to M number. Where in N array the first element of array is N while other are 1 to N-1 (can be repeating).

For example: My array size is N=5 and M=10, first element is always 5 while others from 1 to 4. So it looks like in below iteration. Since except 1st, other elements get generated randomly and I need to find probability for Sum>=10?

    Random_Iteration1: Arr=[5, 3, 2, 1, 3] Sum = 13
    Random_Iteration2: Arr=[5, 1, 1, 1, 1] Sum = 9
    Random_Iteration3: Arr=[5, 1, 2, 2, 1] Sum = 11

I have written below code in Python:

    import numpy as np
    N=5 #array size
    M=10 
    arr = []
    arr.append([N])
    arr.append(np.random.choice(np.arange(1, N), size=N-1).tolist()) 
    arr = sum(arr,[]) #generates array such that 1st element is N, rest are randomly generated elements from 1 to N-1
    arr_sum = np.sum(arr) #gives array sum

    possibilities = N*N
    #numerator = I am not sure what to take here

I would really appreciate any help. Please let me know if any details in explanation are required. Thank you.

1

There are 1 best solutions below

0
On

If your first entry is always $5$, you might as well withdraw it and consider $N=4$, $M=5$. Now, what you are looking for is the probability that a multinomial distribution of parameters $N=4$ and $p = (0.25,0.25,0.25,0.25)$ is greater than $5$. You can calculate it by hand, a Python command can probably do it as well.

https://en.wikipedia.org/wiki/Multinomial_distribution