Erik
Erik

Reputation: 123

Quantile function for mixed von Mises distributions

I want to calculate the quantile function for a mixture of von Mises distribution. I am using the package circular in R, which supports the density, the cumulative probability and sampling from such a model by dmixedvonmises(), pmixedvonmises() and rmixedvonmises(), respectively. However, there are no qmixedvonmises() (Which is what I want). For a single von Mises distribution, they all exist; rvonmises(), dvonmises(), pvonmises() and qvonmises(). Is it difficult to get the function for the quantiles of a mixture of von Mises distributions (given that all model parameters are known)? Can anyone help me with how this function would look like? Are there other packages in R that provides this function?

Upvotes: 3

Views: 277

Answers (1)

Julius Vainora
Julius Vainora

Reputation: 48221

Even in such convenient cases as with normal distribution there is no closed-form expression for that. However, we may use numerical methods.

library(circular)
qmixedvonmises <- function(p, mu1, mu2, kappa1, kappa2, prop) {
  fun <- function(q) pmixedvonmises(q, mu1, mu2, kappa1, kappa2, prop) - p
  suppressWarnings(uniroot(fun, c(0, 2 * pi - 1e-8))$root)
}
qmixedvonmises(0.05, mu1 = circular(0), mu2 = circular(pi), kappa1 = 15, kappa2 = 15, prop = 0.5)
# [1] 0.06599235
qmixedvonmises(0.95, mu1 = circular(0), mu2 = circular(pi), kappa1 = 15, kappa2 = 15, prop = 0.5)
# [1] 6.217193

For more detail see, e.g., here, here, and here.

qmixedvonmises exploits the fact that pmixedvonmises is already available and simply solves numerically for such q that

pmixedvonmises(q) == p

Upvotes: 2

Related Questions