Skip to content

Commit e5e10ef

Browse files
committed
[c]quantile_newton(): sink negation into f(x)
1 parent fa89dda commit e5e10ef

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/quantilealgs.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function newton((f,df), xs::T=mode(d), tol::Real=1e-12) where {T}
6666
end
6767

6868
function quantile_newton(d::ContinuousUnivariateDistribution, p::Real, xs::Real=mode(d), tol::Real=1e-12)
69-
f(x) = -(p - cdf(d, x))
69+
f(x) = cdf(d, x) - p
7070
df(x) = pdf(d, x)
7171
# FIXME: can this be expressed via `promote_type()`? Test coverage missing.
7272
Δ(x) = f(x)/df(x)
@@ -84,7 +84,7 @@ function quantile_newton(d::ContinuousUnivariateDistribution, p::Real, xs::Real=
8484
end
8585

8686
function cquantile_newton(d::ContinuousUnivariateDistribution, p::Real, xs::Real=mode(d), tol::Real=1e-12)
87-
f(x) = -(ccdf(d, x)-p)
87+
f(x) = p - ccdf(d, x)
8888
df(x) = pdf(d, x)
8989
# FIXME: can this be expressed via `promote_type()`? Test coverage missing.
9090
Δ(x) = f(x)/df(x)

0 commit comments

Comments
 (0)