circvar#
- scikitplot.cexternals._astropy.stats.circvar(data, axis=None, weights=None)[source]#
Computes the circular variance of an array of circular data.
There are some concepts for defining measures of dispersion for circular data. The variance implemented here is based on the definition given by [1], which is also the same used by the R package ‘CircStats’ [2].
- Parameters:
- datandarray or
~astropy.units.Quantity Array of circular (directional) data, which is assumed to be in radians whenever
dataisnumpy.ndarray. Dimensionless, if Quantity.- axisint, optional
Axis along which circular variances are computed. The default is to compute the variance of the flattened array.
- weightsnumpy.ndarray, optional
In case of grouped data, the i-th element of
weightsrepresents a weighting factor for each group such thatsum(weights, axis)equals the number of observations. See [1], remark 1.4, page 22, for detailed explanation.
- datandarray or
- Returns:
- circvarndarray or
~astropy.units.Quantity[‘dimensionless’] Circular variance.
- circvarndarray or
- Parameters:
data (NDArray | DummyQuantity)
axis (int | None)
weights (NDArray | None)
- Return type:
NDArray | DummyQuantity
Notes
For Scipy < 1.9.0,
scipy.stats.circvaruses a different definition based on an approximation using the limit of small angles that approaches the linear variance. For Scipy >= 1.9.0,scipy.stats.cirvaruses a definition consistent with this implementation.References
[1] (1,2)S. R. Jammalamadaka, A. SenGupta. “Topics in Circular Statistics”. Series on Multivariate Analysis, Vol. 5, 2001.
[2]C. Agostinelli, U. Lund. “Circular Statistics from ‘Topics in Circular Statistics (2001)’”. 2015. <https://cran.r-project.org/web/packages/CircStats/CircStats.pdf>
Examples
>>> import numpy as np >>> from astropy.stats import circvar >>> from astropy import units as u >>> data = np.array([51, 67, 40, 109, 31, 358])*u.deg >>> circvar(data) <Quantity 0.16356352748437508>