function [R] = HoopStats_K2R(K)
% "HoopStats_K2R"
% R01.01
% By Sam Berens (sam.berens@york.ac.uk).
%
% [R] = HoopStats_K2R(K)
%
% Converts the von Mises concentration parameter (K) to a resultant (mean)
% vector length R;

%% Computation:
if K < 7e-3
    R = K;
elseif (K < 3.648) && (K >= 1.2516)
    R = (-sqrt((10000*K^2 - 19800*K + 33709)) +100*K + 179) / 278;
elseif K < 1.2516
    R = roots([5,0,6,0,12,(-6*K)]);
    R = abs(R(end,1));
else
    R = roots([1,-4,3,(-1/K)]);
    R = abs(R(2));
end

return