Averages/Mean angle: Difference between revisions

m
J: make the second defn consistent with the first
m (J: Added a couple examples, and changed the result (was between _180 and 180, now between 0 and 360))
m (J: make the second defn consistent with the first)
Line 528:
roundComplex=: (* * |)&.+. NB. discard an extraneous least significant bit of precision from a complex value whose magnitude is in the vicinity of 1
avgAngleR=: _1 { [: roundComplex@mean&.toComplex 1 ,. ] NB. calculate average angle in radians
avgAngleD=: 360|avgAngleR&.rfd</lang> NB. calculate average angle in degrees
Example use:
<lang J> avgAngleD 10 350
6,962

edits