Why VonMisesFisher doesn't work for k = 0?

Hello everyone, I was planning to use VonMisesFisher distribution for some modelling purpose like random walk. But when I tried to sample vectors for k=0 which should be giving values following uniform distribution, function gives error.

Is there some other function for uniform sphere distribution?

ERROR: κ must be positive.
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:35
 [2] VonMisesFisher{Float64}(μ::Vector{Float64}, κ::Float64; checknorm::Bool)
   @ Distributions ~/.julia/packages/Distributions/uuqsE/src/multivariate/vonmisesfisher.jl:24
 [3] VonMisesFisher
   @ ~/.julia/packages/Distributions/uuqsE/src/multivariate/vonmisesfisher.jl:20 [inlined]
 [4] VonMisesFisher
   @ ~/.julia/packages/Distributions/uuqsE/src/multivariate/vonmisesfisher.jl:31 [inlined]
 [5] VonMisesFisher(μ::Vector{Float64}, κ::Int64)
   @ Distributions ~/.julia/packages/Distributions/uuqsE/src/multivariate/vonmisesfisher.jl:34
 [6] top-level scope
   @ REPL[38]:1

I can‘t answer the why, but AFAIK this isn‘t the only distribution in Distributions.jl that is not defined on the boundary of the parameter space despite the fact that it would be a well-defined distribution.

The easiest way to generate uniform samples on the sphere is to normalize samples from the standard multivariate normal distribution.

1 Like