Skip to content

Commit 4d021a7

Browse files
committed
[c]quantile_newton(): sink negation into f(x)
1 parent 46f4a10 commit 4d021a7

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
@@ -64,7 +64,7 @@ function newton((f,df), xs::T=mode(d), tol::Real=1e-12) where {T}
6464
end
6565

6666
function quantile_newton(d::ContinuousUnivariateDistribution, p::Real, xs::Real=mode(d), tol::Real=1e-12)
67-
f(x) = -(p - cdf(d, x))
67+
f(x) = cdf(d, x) - p
6868
df(x) = pdf(d, x)
6969
# FIXME: can this be expressed via `promote_type()`? Test coverage missing.
7070
Δ(x) = f(x)/df(x)
@@ -82,7 +82,7 @@ function quantile_newton(d::ContinuousUnivariateDistribution, p::Real, xs::Real=
8282
end
8383

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

0 commit comments

Comments
 (0)