All problems
Natural Parameter to Mean
Problem
Convert the natural parameter of a Bernoulli distribution to its mean:
p = 1 / (1 + exp(-eta))
The logistic sigmoid maps the real line to the interval (0, 1).
Hint
eta = 0 corresponds to a fair coin.
Test cases
case 1
in: [0]
expected: 0.5
case 2
in: [1]
expected: 0.7310585786300049
case 3
in: [-2]
expected: 0.11920292202211755
case 4
in: [5]
expected: 0.9933071490757153
Starter codePython
import math
def bernoulli_natural_to_mean(eta):
# Your code here
pass4 test cases · run your code against them in the editor