# Score function Mittag-Leffler pdf

Good sunday to everyone,

I’ve been trying to compute the score function of the Mittag-Leffler distribution given by the pdf

where d is known as the rate and \alpha as the fractional parameter. So I’ve been trying to compute

\frac{\partial \log f(t;\alpha,d)}{\partial \alpha}

but I haven’t put a lot of thought onto an efficient way of compute this! I just want to check if something works, so I’ve tried to use ForwardDiff.jl together with MittagLeffler.jl, where they use the numerical methods found in this paper
https://www.researchgate.net/publication/237433354_Computation_of_the_Mittag-Leffler_function_and_its_derivatives
and I’ve been trying to do this

using MittagLeffler, ForwardDiff

d = 127.03238985497151
α = 0.8979932142015109
t = 0.008976795220502681

f(α) = log(d*t^(α-1)*mittleff(α,α,-d*t^α))
ForwardDiff.derivative(f,α) #NaN


I sometimes also get this error with other parameters, I got this error with the parameters above but when I rerun it I just get a NaN don’t know why.

ERROR: MethodError: no method matching kronrod(::Type{ForwardDiff.Dual{ForwardDiff.Tag{typeof(f), Float64}, Float64, 1}}, ::Int64)

Closest candidates are:
kronrod(::Any, ::Integer, ::Real, ::Real; rtol, quad)
kronrod(::Type{T}, ::Integer) where T<:AbstractFloat
kronrod(::Integer, ::Real, ::Real)
...

Stacktrace:
[1] macro expansion
[2] _cachedrule
[3] cachedrule
[4] do_quadgk(f::MittagLeffler.var"#1#2"{…}, s::Tuple{…}, n::Int64, atol::Nothing, rtol::Nothing, maxevals::Int64, nrm::typeof(LinearAlgebra.norm), segbuf::Nothing)
@ ~/.julia/packages/MittagLeffler/8sEkJ/src/mittag_leffler.jl:24 [inlined]
[11] Kint
@ ~/.julia/packages/MittagLeffler/8sEkJ/src/mittag_leffler.jl:27 [inlined]
[12] Kint
@ ~/.julia/packages/MittagLeffler/8sEkJ/src/mittag_leffler.jl:35 [inlined]
[13] mittleffints(α::ForwardDiff.Dual{…}, β::ForwardDiff.Dual{…}, z::ForwardDiff.Dual{…}, ρ::Float64)
@ MittagLeffler ~/.julia/packages/MittagLeffler/8sEkJ/src/mittag_leffler.jl:118
[14] _mittleff_slow_with_eps(α::ForwardDiff.Dual{…}, β::ForwardDiff.Dual{…}, z::Complex{…}, ρ::Float64)
@ MittagLeffler ~/.julia/packages/MittagLeffler/8sEkJ/src/mittag_leffler.jl:197 [inlined]
[15] _mittleff0(α::ForwardDiff.Dual{…}, β::ForwardDiff.Dual{…}, z::ForwardDiff.Dual{…})
@ MittagLeffler ~/.julia/packages/MittagLeffler/8sEkJ/src/mittag_leffler.jl:216
[16] _mittleff
@ MittagLeffler ~/.julia/packages/MittagLeffler/8sEkJ/src/mittag_leffler.jl:200 [inlined]
[17] mittleff(α::ForwardDiff.Dual{…}, β::ForwardDiff.Dual{…}, z::ForwardDiff.Dual{…})
@ MittagLeffler ~/.julia/packages/MittagLeffler/8sEkJ/src/mittag_leffler.jl:168
[18] f(α::ForwardDiff.Dual{ForwardDiff.Tag{typeof(f), Float64}, Float64, 1})
@ Main ./REPL[5]:1
[19] derivative(f::typeof(f), x::Float64)
@ ForwardDiff ~/.julia/packages/ForwardDiff/PcZ48/src/derivative.jl:14
[20] top-level scope
@ REPL[6]:1



I’ve seen this in the repo:
mittleff fails for some arguments. In particular, some of those that evaluate integrals.

So my guess is that it is the package producing the error and not the ForwardDiff, or maybe quadrature rules cannot be forwarddiffed?

Could I have some advice? I’m thinking of this options I have

1. Try to implement myself the numerical method and hope that automatic differentiation applies.
2. Try to tackle directly the score function by myself theoretically.

Will automatic differentiation be as fast as me trying to find a quadrature for the score function? Is just using finite differences a bad idea?
There is no literature over score functions of the Mittag-Leffler density!