Coefficient of Variation (CV) and Coefficient of Quartile Variation (CQV) with Confidence Intervals (CI)
Project description
pycvcqv
Introduction
pycvcqv provides some easy-to-use functions to calculate the
Coefficient of Variation (cv) and Coefficient of Quartile Variation (cqv)
with confidence intervals provided with all available methods.
Install
pip install pycvcqv
Usage
import pandas as pd
from pycvcqv import coefficient_of_variation, cqv
coefficient_of_variation(
data=[
0.2, 0.5, 1.1, 1.4, 1.8, 2.3, 2.5, 2.7, 3.5, 4.4,
4.6, 5.4, 5.4, 5.7, 5.8, 5.9, 6.0, 6.6, 7.1, 7.9
],
multiplier=100,
ndigits=2
)
# {'cv': 57.77, 'lower': 41.43, 'upper': 98.38}
cqv(
data=[0.2, 0.5, 1.1, 1.4, 1.8, 2.3, 2.5, 2.7, 3.5, 4.4, 4.6, 5.4, 5.4],
multiplier=100,
)
# 51.7241
data = pd.DataFrame(
{
"col-1": pd.Series([0.2, 0.5, 1.1, 1.4, 1.8, 2.3, 2.5, 2.7, 3.5]),
"col-2": pd.Series([5.4, 5.4, 5.7, 5.8, 5.9, 6.0, 6.6, 7.1, 7.9]),
}
)
coefficient_of_variation(data=data, num_threads=3)
# columns cv lower upper
# 0 col-1 0.6076 0.3770 1.6667
# 1 col-2 0.1359 0.0913 0.2651
cqv(data=data, num_threads=-1)
# columns cqv
# 0 col-1 0.3889
# 1 col-2 0.0732
Confidence-interval methods for cv
coefficient_of_variation accepts a method argument that selects the
confidence-interval estimator. The closed-form methods listed below are
ported math-for-math from the R cvcqv
package.
from pycvcqv import coefficient_of_variation
x = [
0.2, 0.5, 1.1, 1.4, 1.8, 2.3, 2.5, 2.7, 3.5, 4.4,
4.6, 5.4, 5.4, 5.7, 5.8, 5.9, 6.0, 6.6, 7.1, 7.9,
]
for method in (
"kelley", "mckay", "miller", "vangel",
"mahmoudvand_hassani", "equal_tailed",
"shortest_length", "normal_approximation",
):
print(method, coefficient_of_variation(
data=x, method=method, multiplier=100, ndigits=3,
))
The output (95% CI, multiplier=100, ndigits=3):
| method | est | lower | upper | description |
|---|---|---|---|---|
kelley |
57.774 | 41.303 | 97.950 | cv with Kelley 95% CI |
mckay |
57.774 | 41.441 | 108.483 | cv with McKay 95% CI |
miller |
57.774 | 34.053 | 81.495 | cv with Miller 95% CI |
vangel |
57.774 | 40.955 | 103.931 | cv with Vangel 95% CI |
mahmoudvand_hassani |
57.774 | 43.476 | 82.857 | cv with Mahmoudvand-Hassani 95% CI |
equal_tailed |
57.774 | 43.937 | 84.383 | cv with Equal-Tailed 95% CI |
shortest_length |
57.774 | 42.015 | 81.013 | cv with Shortest-Length 95% CI |
normal_approximation |
57.774 | 44.533 | 85.272 | cv with Normal Approximation 95% CI |
The bootstrap-based methods (norm, basic, perc, bca) are not yet
ported.
Credits
This project was generated with
python-package-template
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pycvcqv-0.4.1.tar.gz.
File metadata
- Download URL: pycvcqv-0.4.1.tar.gz
- Upload date:
- Size: 20.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
76003bf99a09a47bdd28523e1a1e9f8f4a65e17bc082638ca0c35bccc99e9d9c
|
|
| MD5 |
9414bfaf113bb453d8fdc0348811a862
|
|
| BLAKE2b-256 |
817b9ebd99cd884c9834482db9f0cc44934311e2e9db2f2030a7625fb27dedef
|
File details
Details for the file pycvcqv-0.4.1-py3-none-any.whl.
File metadata
- Download URL: pycvcqv-0.4.1-py3-none-any.whl
- Upload date:
- Size: 35.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a42974ef41521b7469c5e7dbcd0b705ca4adf2f24de908b0abc24b056657668
|
|
| MD5 |
fcf07174b94676450791b7a0082f2454
|
|
| BLAKE2b-256 |
28965d29abffb5031a9437a08b08364d0f5b5c8ca3629c0e97753740efde7154
|