@@ -19,28 +19,26 @@ using Statistics: Statistics
1919using LinearAlgebra: LinearAlgebra
2020
2121export maximum_a_posteriori, maximum_likelihood
22- # The MAP and MLE exports are only needed for the Optim.jl interface.
23- export MAP, MLE
2422
2523"""
2624 ModeEstimator
2725
2826An abstract type to mark whether mode estimation is to be done with maximum a posteriori
29- (MAP) or maximum likelihood estimation (MLE). This is only needed for the Optim.jl interface.
27+ (MAP) or maximum likelihood estimation (MLE).
3028"""
3129abstract type ModeEstimator end
3230
3331"""
3432 MLE <: ModeEstimator
3533
36- Concrete type for maximum likelihood estimation. Only used for the Optim.jl interface.
34+ Concrete type for maximum likelihood estimation.
3735"""
3836struct MLE <: ModeEstimator end
3937
4038"""
4139 MAP <: ModeEstimator
4240
43- Concrete type for maximum a posteriori estimation. Only used for the Optim.jl interface.
41+ Concrete type for maximum a posteriori estimation.
4442"""
4543struct MAP <: ModeEstimator end
4644
@@ -123,32 +121,6 @@ required by Optimization.jl.
123121(f:: OptimLogDensity )(z:: AbstractVector ) = - LogDensityProblems. logdensity (f. ldf, z)
124122(f:: OptimLogDensity )(z, _) = f (z)
125123
126- # NOTE: The format of this function is dictated by Optim. The first argument sets whether to
127- # compute the function value, the second whether to compute the gradient (and stores the
128- # gradient). The last one is the actual argument of the objective function.
129- function (f:: OptimLogDensity )(F, G, z)
130- if G != = nothing
131- # Calculate log joint and its gradient.
132- logp, ∇logp = LogDensityProblems. logdensity_and_gradient (f. ldf, z)
133-
134- # Save the negative gradient to the pre-allocated array.
135- copyto! (G, - ∇logp)
136-
137- # If F is something, the negative log joint is requested as well.
138- # We have already computed it as a by-product above and hence return it directly.
139- if F != = nothing
140- return - logp
141- end
142- end
143-
144- # Only negative log joint requested but no gradient.
145- if F != = nothing
146- return - LogDensityProblems. logdensity (f. ldf, z)
147- end
148-
149- return nothing
150- end
151-
152124"""
153125 ModeResult{
154126 V<:NamedArrays.NamedArray,
0 commit comments