I came across a question as below
Assume a series includes integer from 1 to N. Every time one samples an integer without replacement from the series. The process continues if $X_{n}$ >= $X_{n-1}$, and $X_{n}$ will be saved into another series $X_{s}$. The process won't stop until $X_{n}$ < $X_{n-1}$.
Then it asks the expected length of $X_{s}$.
Below I tried to simulate the output in Python
import numpy as np
def gen():
'''
return length of X_s
'''
N = 10000
raw_data = list(np.arange(N)) #1,2,3,...,N
X_s = []
last_value = - float('inf')
for _ in range(N):
cur_value = np.random.choice(raw_data)
raw_data.pop(cur_value)
if cur_value >= last_value:
last_value = cur_value
X_s.append(last_value)
else:
break
return len(X_s)
a = [gen() for _ in range(1000)] # simulate 1000 times
np.mean(a)
The result is around 1.6~1.7. I am looking for a closed form solution for the expected length, any thoughts?