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