A robot log contains two planar heading observations: 179 degrees and minus 179 degrees. Adding the displayed numbers and dividing by two produces zero. On a compass-like diagram, however, both observations point almost toward the negative x direction. Their separation is only two degrees. The numerical midpoint points toward positive x, nearly opposite the observations it is supposed to summarize.
This is a mismatch between the arithmetic operation and the quantity being represented. A directed planar heading repeats after a full revolution. Its printed value has a boundary; the physical direction has no corresponding seam. An average intended to describe direction must account for that periodicity before the result receives a label such as “mean heading.”
The discussion here concerns a single directed angle in a plane, measured counterclockwise from positive x. It does not define an average of arbitrary three-dimensional orientations. The examples are original mathematical illustrations, not measurements from a robot or a test of a particular software installation.
SciPy's circmean documentation defines a circular mean from the argument of an average of complex unit vectors. Astropy also provides a circular-mean function, with angular units and weighting documented in its interface. These official references establish the statistical operation. The examples below examine what its output can and cannot mean.
Two observations become two arrows
For an angle theta, form the unit vector (cos(theta), sin(theta)). Average the horizontal components to obtain C and the vertical components to obtain S. The circular mean direction is atan2(S, C), provided that the resulting vector has a defined direction. Trigonometric calculations require consistent angular units; the numerical examples are displayed in degrees.
For 179 degrees and minus 179 degrees, both horizontal components are approximately minus 0.999847695. Their vertical components have equal magnitudes and opposite signs. Therefore C is approximately minus 0.999847695 and S is zero. The mean direction is 180 degrees, equivalently minus 180 degrees under another output convention.
Changing the second printed observation from minus 179 degrees to 181 degrees does not change either input vector. It therefore does not change the circular mean. An ordinary arithmetic mean changes from zero to 180 degrees under that relabeling. This dependence on an arbitrary representation boundary reveals why the ordinary mean was unsuitable for this directional question.
The length of the average vector matters
The angle alone discards useful information. Define the mean resultant length R as sqrt(C squared plus S squared). For equally weighted unit vectors, R lies between zero and one. In this example, R is approximately 0.999847695. The two arrows strongly reinforce one another, and their mean direction describes their common heading closely.
Now replace the observations with zero and 180 degrees. These are physically opposite directions. In exact arithmetic their unit vectors cancel, giving C = 0, S = 0, and R = 0. A zero vector has no direction. There is no unique circular mean angle available from this construction.
A software return value does not remove that mathematical ambiguity. The SciPy v1.18.0 page explicitly describes an implementation-defined, input-dependent return within the requested range when the mean resultant vector is zero. It does not promise that this case will always produce NaN. Small floating-point remnants can also make a mathematically cancelling vector appear to have a numerical angle.
Near cancellation can be sensitive before exact cancellation occurs. Consider zero and 179.8 degrees. Their circular mean is 89.9 degrees, while R is only about 0.00174533. Change the second observation to minus 179.8 degrees. The mean becomes minus 89.9 degrees, with the same small R. A 0.4-degree change across the boundary in that second direction has moved the reported mean by almost 180 degrees.
This behavior follows from a nearly cancelled vector, not from a mysterious discontinuity in the robot. The individual observations are nearly opposed. Their small imbalance determines which perpendicular direction the average favors. Reporting only the mean would hide that sensitivity.
Agreement, weighting, and the question being answered
A low R does not automatically mean that every observation is noisy. Two precise groups pointing in opposite directions can produce a weak resultant. A high R also does not certify sensor accuracy: many observations can agree around a shared offset. R describes directional concentration under the chosen representation and weights; it is not a universal confidence score.
Weights change the population being summarized. If three equally credible observations are at 179 degrees and one is at minus 179 degrees, averaging all four vectors produces a direction of approximately 179.49996 degrees. The result moves toward the more frequent direction. Assigning extra weight for some other reason requires a corresponding interpretation of that weight; it does not create missing evidence.
The model also assumes directed angles with a full-turn period. An unoriented line has different symmetry: a line at zero degrees is the same line at 180 degrees. Feeding such axial data directly into the directed-heading construction would turn equivalent line orientations into cancelling arrows. Establishing the physical period precedes choosing an averaging formula.
A joint's accumulated travel is another quantity
A rotating mechanism can have a heading and an accumulated angular position. Positions of zero degrees and 360 degrees share the same direction, but they can represent different turn counts. Circular averaging deliberately removes that distinction. It cannot preserve winding information that was discarded when angles were reduced modulo a full turn.
A joint with finite travel limits may therefore need an unwrapped position description rather than a directional mean. Continuity assumptions can help unwrap a sequence when sufficient motion information exists, but a circular average cannot reconstruct an unknown history of revolutions. A direction estimate and a mechanical travel estimate serve different purposes even when both are printed in degrees.
The useful result is consequently more than one number. The represented quantity, angular period, output interval, weighting rule, and resultant strength give the mean its meaning. At a wrap boundary, the vector construction can repair a misleading arithmetic average. At cancellation, its shrinking vector instead reveals that a single representative direction is becoming inadequate.
Sources and scope
SciPy, circmean, official documentation titled v1.18.0 when checked:
https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.circmean.html
Astropy, circmean, official stable web documentation, footer updated October 15, 2026. The stable URL is not an installed-version guarantee:
https://docs.astropy.org/en/stable/api/astropy.stats.circmean.html
Sources checked October 23, 2026. All numerical examples are hypothetical calculations.
Illustration note: The accompanying site-library robot and computer scene is a conceptual illustration of robot data interpretation. It does not depict a verified heading experiment, a specific circular-mean implementation, or measured accuracy.