Skip to content

Commit e0347cc

Browse files
committed
fix accuracy of logit
Fixes #98
1 parent 30b15e3 commit e0347cc

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/basicfuns.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,13 @@ for ``0 < x < 1``.
120120
121121
Its inverse is the [`logistic`](@ref) function.
122122
"""
123-
logit(x::Real) = log(x / (one(x) - x))
123+
function logit(x::Real)
124+
if 4 * x < 1
125+
-log(inv(x) - 1)
126+
else
127+
2 * atanh(2*x - 1)
128+
end
129+
end
124130

125131
"""
126132
$(SIGNATURES)

0 commit comments

Comments
 (0)