I'm simulating values from a Von Mises Distribuited random variable with $\mu=15$ and $\kappa=2$(concentration parameter). I just know that MLE for $\mu$ is:
\begin{cases} arctan\left(\dfrac{s}{c}\right), & s\ge 0 ~and~ c>0 \\ arctan\left(\dfrac{s}{c}\right) + \pi, & c<0 \\ arctan\left(\dfrac{s}{c}\right) + 2\pi, & s<0 ~and~ c>0 \end{cases}
Where $c=\sum_{i=1}^{n}cos(x_i)$ and $ s=\sum_{i=1}^{n}sin(x_i)$, but the estimated value isn't the same value that I set in the random generation function. I'm using R package called $\texttt{circular}$
This is my code to generate the values:
n=100
x=rvonmises(n,circular(15),2,control.circular=list(units="radians"))
mediacirc=function(x){
mu=0
s=sum(sin(x))
c=sum(cos(x))
arc=atan(s/c)
if(s>=0 && c>0){
mu=arc
}else {
if(c<0){
mu=arc+pi
}else{
if(s<0 && c>0){
mu=arc+2*pi
}
}
}
return(mu)
}
mediacirc(x)
output: 2.446833
As you can see, this implementation returns 2.446833 for mean value. But I generate a sample with a mean equal to 15.
What's going on with my code?
Thanks for all help!
The von Mises distribution has a support on a circle so an interval of length $2\pi$ representing direction, typically $[0,2\pi)$ or $(-\pi,\pi]$.
So $15$ gets cut down to this interval with $$15 \approx 4 \pi + 2.433629386$$