Circular Data Base
Circular
Circular Data Analysis Object.
This class encapsulates circular data and provides tools for descriptive statistics, hypothesis testing, and visualization. It automatically computes key circular statistics and tests when the data are loaded.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
array - like(n)
|
The raw circular data, typically in degrees, radians, or other angular units. |
required |
w
|
array - like(n) or None
|
Frequencies or weights for the data points. If None, all data points are treated equally. Default is None. |
None
|
bins
|
(int, array - like(n + 1) or None)
|
Number of bins or bin edges to group the data. If None, the data is not binned. Default is None. |
None
|
unit
|
str
|
Unit of the input data. Must be one of {"degree", "radian", "hour"}. Default is "degree". |
'degree'
|
n_intervals
|
int, float, or None
|
Number of intervals in a full cycle. If None, the value is inferred based on the unit:
Custom intervals require explicit input. Default is None. |
None
|
n_clusters_max
|
int
|
Maximum number of clusters to test for a mixture of von Mises distributions. Default is 1. |
1
|
kwargs
|
dict
|
Additional keyword arguments to customize the computation of statistics such as the median. |
{}
|
Attributes:
Name | Type | Description |
---|---|---|
n |
int
|
Total sample size, including weights. |
mean |
float
|
Angular mean in radians. |
mean_ci |
tuple of float
|
Confidence interval for the angular mean, if applicable. |
median |
float
|
Angular median in radians. |
median_ci |
tuple of float
|
Confidence interval for the angular median, if computed. |
r |
float
|
Resultant vector length, measuring data concentration (0 to 1). |
kappa |
float
|
Concentration parameter, measuring data sharpness. |
s |
float
|
Angular deviation, measuring data dispersion. |
skewness |
float
|
Circular skewness of the data. |
kurtosis |
float
|
Circular kurtosis of the data. |
R |
float
|
Rayleigh's R statistic, derived from the resultant vector length. |
mixtures |
list
|
Mixture models of von Mises distributions fitted to the data (if |
Methods:
Name | Description |
---|---|
summary |
Returns a detailed summary of the computed statistics. |
plot |
Visualizes the circular data, including histograms and other representations. |
Notes
- Angular data is automatically converted to radians for internal computations.
- Data can be grouped or ungrouped. Ungrouped data is handled by assigning equal weights.
- The Rayleigh test for angular mean is computed, with p-values indicating significance.
- Confidence intervals for the angular mean are approximated using either bootstrap or dispersion methods, depending on the sample size and significance.
References
- Zar, J. H. (2010). Biostatistical Analysis (5th Edition). Pearson.
- Fisher, N. I. (1995). Statistical Analysis of Circular Data. Cambridge University Press.
Examples:
Basic Usage
data = [30, 60, 90, 120, 150]
circ = Circular(data, unit="degree")
print(circ.summary())
Grouped Data
data = [0, 30, 60, 90]
weights = [1, 2, 3, 4]
circ = Circular(data, w=weights, unit="degree")
print(circ.summary())
Source code in pycircstat2/base.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 |
|
summary()
Summary of basic statistics for circular data.
This method generates a textual summary of the key descriptive and inferential statistics computed for the circular data. It provides information about the data type, concentration, dispersion, and more.
The summary includes the following components:
-
Grouping:
Indicates whether the data is grouped (binned) or ungrouped.
-
Unimodality:
For models with mixtures of von Mises distributions, it specifies whether the data is unimodal or multimodal, along with the number of clusters if applicable.
-
Data Characteristics:
- The unit of measurement (e.g., degrees, radians, hours).
- Total sample size, including weights if provided.
-
Angular Mean:
- The angular mean, with its corresponding p-value from the Rayleigh test.
- The confidence interval (CI) for the angular mean, if available.
-
Angular Median:
- The angular median, representing the central tendency.
- The confidence interval (CI) for the angular median, if applicable.
-
Measures of Dispersion:
- Angular deviation (\(s\)): A measure of spread in circular data.
- Circular standard deviation (\(s_0\)): An alternative dispersion measure.
-
Measures of Concentration:
- Resultant vector length (\(r\)): A measure of data concentration, ranging from 0 (uniform) to 1 (highly concentrated).
- Concentration parameter (\(\kappa\)): Indicates sharpness or clustering of the data.
-
Higher-Order Statistics:
- Circular skewness: A measure of asymmetry.
- Circular kurtosis: A measure of peakedness or flatness relative to a uniform distribution.
-
Significance Codes:
- A guide to interpret the p-values of statistical tests.
-
Methods:
- The method used for calculating the angular median.
- The method used for estimating confidence intervals for the angular mean.
Source code in pycircstat2/base.py
370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 |
|
plot(ax=None, kind=None, **kwargs)
Visualize circular data.
This method provides various visualization options for circular data, including scatter
plots, density plots, and rose diagrams. It is a wrapper around the circ_plot
function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ax
|
Axes
|
The matplotlib Axes object where the plot will be drawn. If None, a new Axes object is created. Default is None. |
None
|
kind
|
str or None
|
Deprecated. Use |
None
|
**kwargs
|
dict
|
Additional parameters for customizing the plot. Examples include:
|
{}
|
Returns:
Name | Type | Description |
---|---|---|
ax |
Axes
|
The matplotlib Axes object containing the plot. |
Notes
- This method supports both grouped and ungrouped data.
- Density estimation can be performed using either nonparametric methods or mixtures of von Mises distributions.
- The rose diagram represents grouped data as a histogram over angular bins.
- Confidence intervals for the mean and median are plotted as arcs on the circle.
Examples:
Basic scatter plot
data = [30, 60, 90, 120, 150]
circ = Circular(data, unit="degree")
circ.plot(marker_color="blue", marker_size=15)
Rose diagram with density
circ.plot(plot_rose=True, plot_density=True, bins=18)
Customized plot with radial grid and legend
circ.plot(plot_grid=True, plot_spine=True, plot_mean=True)
Source code in pycircstat2/base.py
431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 |
|