Change of type results in totally different error

Real is an abstract type which means that the vector L will be able to hold any subtype of Real. This will severely hurt performance and may have led to the error you’re seeing due to type instability (I’m on mobile so haven’t checked thoroughly).

You can probably declare the L like this: Vector{eltype(p)}(). This will make an empty vector for holding the same type of element as the array p in your mle_Loglikelihood function.

I would recommend reading the section on performance tips in the docs, specifically the part on abstract containers: Performance Tips · The Julia Language

2 Likes