Averages/Mean angle: Difference between revisions

(Add Swift)
Line 986:
Julia has built-in functions <code>sind</code> and <code>cosd</code> to compute the sine and cosine of angles specified in degrees accurately (avoiding the roundoff errors incurred in conversion to radians), and a built-in function to convert radians to degrees (or vice versa). Using these:
<lang julia>using Statistics
meandegrees(degrees) = radians2degreesrad2deg(atan2atan(mean(sind.(degrees)), mean(cosd.(degrees))))</lang>
The output is:
<lang julia>julia> meandegrees([350, 10])
Anonymous user