Skip to content
DeepForgeby svx
All problems
MediumInformation Theoryinfo-253

Dual Flatness Check

Problem

Check whether the Bernoulli family looks dually flat at the given parameters. Mix the natural parameters linearly, eta_mix = (1 - alpha) * eta1 + alpha * eta2, and return True when sigmoid(eta_mix) matches the same linear mixture of the individual means within 1e-9.

Hint

The sigmoid is nonlinear, so only symmetric parameter pairs stay affine.

Test cases

case 1
in: [0,0,0.5]
expected: true
case 2
in: [1,-1,0.5]
expected: true
case 3
in: [1,2,0.5]
expected: false
case 4
in: [2,-2,0.25]
expected: false
Starter codePython
import math
def dual_flatness_check(eta1, eta2, alpha):
    # Your code here
    pass

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