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

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

return