Skip to content
DeepForgeby svx
All problems
EasyCalculusca-247

Fisher Information for Bernoulli

Problem

For a Bernoulli random variable with success probability p, the Fisher information is I(p) = 1 / (p * (1 - p)).

Given p with 0 < p < 1, return I(p). The information is symmetric about p = 0.5 and diverges at the boundaries.

Hint

The Fisher information is the expected squared score, which is largest near fair coins.

Test cases

case 1
in: [0.5]
expected: 4
case 2
in: [0.25]
expected: 5.333333333333333
case 3
in: [0.1]
expected: 11.111111111111109
case 4
in: [0.9]
expected: 11.111111111111112
Starter codePython
def fisher_bernoulli(p):
    # Your code here
    pass

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