private static double estimateKappa(double r)
{
// Best and Fisher (1981) gave a simple
// approximation to the MLE of kappa:
double r3 = r * r * r;
if (r < 0.53)
{
double r5 = r3 * r * r;
return (2.0 * r) + (r3) + (5.0 * r5 / 6.0);
}
if (r < 0.85)
{
return -0.4 + 1.39 * r + 0.43 / (1.0 - r);
}
return 1.0 / (r3 - 4 * r * r + 3 * r);
// However, Sun (2006) mentions this estimate of k
// is not reliable when r is small, such as when r < 0.7.
}