Skip to content
DeepForgeby svx
All problems
EasyProbabilitypr-149

Expected Record Values

Problem

Expected number of records (left-to-right maxima) in n independent continuous observations:

E[records] = H_n = 1 + 1/2 + ... + 1/n.

The k-th observation is a record with probability 1 / k. Return 0.0 for n <= 0.

Hint

Use indicators and linearity of expectation.

Test cases

case 1
in: [1]
expected: 1
case 2
in: [2]
expected: 1.5
case 3
in: [5]
expected: 2.283333333333333
case 4
in: [0]
expected: 0
Starter codePython
def expected_records(n):
    # Your code here
    pass

4 test cases · run your code against them in the editor