All problems
CEM Elite Sample Count
Problem
Compute how many candidates the cross-entropy method keeps as elites.
Return floor(population * elite_fraction) raised to at least 1 and capped at population. A non-positive population or fraction returns 0.
Hint
At least one elite is kept so the distribution always has a target to refit.
Test cases
case 1
in: [100,0.1]
expected: 10
case 2
in: [100,0.05]
expected: 5
case 3
in: [7,0.1]
expected: 1
case 4
in: [10,1]
expected: 10
case 5
in: [0,0.5]
expected: 0
Starter codePython
import math
def cem_elite_count(population, elite_fraction):
# Your code here
pass5 test cases · run your code against them in the editor