Skip to content
DeepForgeby svx
All problems

Group Size For Learning Signal

Problem

Find the smallest GRPO group size whose probability of containing both a success and a failure reaches threshold.

For group size g that probability is 1 - p ** g - (1 - p) ** g. Return -1 if no size up to max_group qualifies or if p is not strictly between 0 and 1.

Hint

Groups where every sample succeeds or every sample fails produce zero advantages.

Test cases

case 1
in: [0.5,0.8,4]
expected: 4
case 2
in: [0.5,0.7,4]
expected: 3
case 3
in: [0.1,0.5,4]
expected: -1
case 4
in: [0,0.5,8]
expected: -1
case 5
in: [1,0.5,8]
expected: -1
Starter codePython
def group_size_for_signal(p, threshold, max_group):
    # Your code here
    pass

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