Skip to content

Commit 46ccaaf

Browse files
committed
newton(): defer to Roots.jl implementation
1 parent 2df55bc commit 46ccaaf

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ PDMats = "90014a1f-27ba-587c-ab20-58faa44d9150"
1313
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
1414
QuadGK = "1fd47b50-473d-5c70-9696-f719f8f3bcdc"
1515
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
16+
Roots = "f2b01f46-fcfa-551c-844a-d8ac1e96c665"
1617
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
1718
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
1819
StatsAPI = "82ae8749-77ed-4fe6-ae5f-f523153014b0"
@@ -48,6 +49,7 @@ PDMats = "0.10, 0.11"
4849
Printf = "<0.0.1, 1"
4950
QuadGK = "2"
5051
Random = "<0.0.1, 1"
52+
Roots = "2"
5153
SparseArrays = "<0.0.1, 1"
5254
SpecialFunctions = "1.2, 2"
5355
StableRNGs = "1"

src/quantilealgs.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ function newton_impl(Δ, xs::T=mode(d), xrtol::Real=1e-12) where {T}
6161
end
6262

6363
function newton((f,df), xs::T=mode(d), xrtol::Real=1e-12) where {T}
64-
Δ(x) = f(x)/df(x)
65-
return newton_impl(Δ, xs, xrtol)
64+
return find_zero((f,df), xs, Roots.Newton(), xatol=0, xrtol=xrtol, atol=0, rtol=eps(float(T)), maxiters=typemax(Int))
6665
end
6766

6867
function quantile_newton(d::ContinuousUnivariateDistribution, p::Real, xs::Real=mode(d), xrtol::Real=1e-12)

0 commit comments

Comments
 (0)