Welcome to Circular Statistics’s documentation!

Circular Statitics methods for performing statistics operations such as the conversation between ranges, distance between angles, average and pearson correlation.

circular_statistics.CONVERSION_TABLE = {(-180, 180): {(-180, 180): <function <lambda>>, (-3.141592653589793, 3.141592653589793): <built-in function radians>, (0, 6.283185307179586): <function <lambda>>, (0, 360): <function _covert_180_to_360>}, (-3.141592653589793, 3.141592653589793): {(-180, 180): <built-in function degrees>, (-3.141592653589793, 3.141592653589793): <function <lambda>>, (0, 6.283185307179586): <function _covert_pi_to_2pi>, (0, 360): <function <lambda>>}, (0, 6.283185307179586): {(-180, 180): <function <lambda>>, (-3.141592653589793, 3.141592653589793): <function _covert_2pi_to_pi>, (0, 6.283185307179586): <function <lambda>>, (0, 360): <built-in function degrees>}, (0, 360): {(-180, 180): <function _covert_360_to_180>, (-3.141592653589793, 3.141592653589793): <function <lambda>>, (0, 6.283185307179586): <built-in function radians>, (0, 360): <function <lambda>>}}

Table implements as dictionary of dictionaries that receives two tuples of representations of angles, and converts the given value from the range of the first tuple to second one.

For example: CONVERSION_TABLE[(0,360)][(-180,180)](270) will output -90.

available ranges are:
  • (0, 360)

  • (-180, 180)

  • (0, \(2\pi\))

  • (\(-\pi\), \(\pi\))

circular_statistics.angle_distance_degree(deg1: float, deg2: float) → float[source]

Return the distance between angles.

Parameters
  • deg1 – the starting angle, in degrees.

  • deg2 – the ending angle, in degrees.

Returns

the distance in range [-180, 180]

circular_statistics.angle_distance_radians(rad1: float, rad2: float) → float[source]

Return the distance between angles.

Parameters
  • rad1 – the starting angle, in radians.

  • rad2 – the ending angle, in radians.

Returns

the distance in range [\(-\pi\) , \(\pi\)]

circular_statistics.compute_pearson_circular_correlation(x: numpy.ndarray, input_range_x: Union[Tuple[int, int], Tuple[float, float]], y: numpy.ndarray, input_range_y: Union[Tuple[int, int], Tuple[float, float]]) → float[source]

Computes Pearson’s circular product-moment correlation coefficients for pairs of collections.

Parameters
  • x – first array of angles

  • input_range_x – input range of x

  • y – second array of angles

  • input_range_y – input range of y

Returns

Pearson’s circular correlation coefficient for the two collections.

circular_statistics.degrees_angles_average(x: numpy.ndarray) → float[source]

Calculates the average between degree angles.

Parameters

x – numpy array of degree angles in range (0, 360) or (-180, 180).

Returns

the average.

circular_statistics.radians_angles_average(x: numpy.ndarray) → float[source]

Calculates the average between radian angles.

Parameters

x – numpy array of degree angles in range (0, \(2\pi\)) or (\(-\pi\), \(\pi\)).

Returns

the average.