StackOverflowError when fitting data to a von Mises distribution

Hi everyone.

I’m trying to use Turing.jl to fit data to a von Mises circular distribution, and I am having some “stack overflow” issues during the fitting.

This is my (very simple) code (coin flip adaptation):

using Turing
using Distributions

μ = 0; κ = 517
vm = VonMises(μ, κ)
data = rand(vm, 100)

@model model(x) = begin
    μ ~ Normal(0, 10)
    κ ~ Uniform(450, 550)
    N = length(x)
    for n in 1:N
        x[n] ~ VonMises(μ, κ)

ϵ = 0.05
τ = 10
iterations = 1000

chain = sample(model(data), HMC(ϵ, τ), iterations, progress=false)

The error is “StackOverflowError: in besselix at SpecialFunctions/LC8dm/src/bessel.jl:583”

Thank you very much in advance.

This is a known issue One fix is to have a pure Julia implementation of the besselix function.

1 Like

If you are up for the task, check this

1 Like

Hi Mohamed.

Thank you very much for your quick answer. I didn’t know about the issue (absolute beginner in Julia). I shall take a look to the references you sent to me.

Many thanks again.

1 Like


I’d also be very interested in getting von Mises distributions distributions working.

When you say a pure Julia function is needed, are there any specific requirements for that? Would a straight conversion of and associated functions be suitable, or does it have to match a technique already used in SpecialFunctions?


1 Like