Skip to main content

pycvcqv

PyPI Python Version Build status coverage report Downloads "Buy Me A Coffee" static analysis dependencies vulnerabilities maintainability complexity lint report docstring Code style: black Security: bandit Pre-commit License

Find homogeneity with confidence.

Python port of cvcqv

Introduction

pycvcqv provides versatile functions to quantify homogeneity with confidence intervals. It offers a variety of well-established methods from the literature (Kelley, McKay, Miller, Vangel, Mahmoudvand-Hassani, Equal-Tailed, Shortest-Length, Normal Approximation, Bonett, and the Abu-Shawiesh-Akyuz-Kibria adjusted-degrees-of-freedom, large-sample, and augmented-large-sample CIs) and bootstrap resampling techniques (Normal, Basic, Percentile, BCa) for constructing confidence intervals on the Coefficient of Variation (cv) and the Coefficient of Quartile Variation (cqv).

Coefficient of Variation

cv is a measure of relative dispersion representing the degree of variability relative to the mean (Albatineh et al., 2014). Since cv is unitless, it is useful for comparing variables that have different units. It is also a measure of homogeneity (Albatineh et al., 2014).

Coefficient of Quartile Variation

cqv is a measure of relative dispersion based on the interquartile range (IQR). Since cqv is unitless, it is also useful for comparing variables that have different units. It is also a measure of homogeneity (Bonett, 2006; Altunkaynak, 2018).

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.

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",
    "aak_adj", "aak_ls", "aak_als",
    "norm", "basic", "perc", "bca",
):
    print(method, coefficient_of_variation(
        data=x,
        method=method,
        multiplier=100,
        ndigits=3,
        num_replicates=10000,
        random_state=42,
    ))

Output (95% CI, multiplier=100, ndigits=3, bootstrap methods use num_replicates=10000, random_state=42):

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
aak_adj 57.774 48.029 72.516 cv with Abu-Shawiesh-Akyuz-Kibria Adjusted-DoF 95% CI
aak_ls 57.774 46.310 72.075 cv with Abu-Shawiesh-Akyuz-Kibria Large-Sample 95% CI
aak_als 57.774 45.839 75.092 cv with Abu-Shawiesh-Akyuz-Kibria Augmented-LS 95% CI
norm 57.774 38.850 78.379 cv with Normal Approximation Bootstrap 95% CI
basic 57.774 37.716 77.166 cv with Basic Bootstrap 95% CI
perc 57.774 38.382 77.832 cv with Bootstrap Percentile 95% CI
bca 57.774 41.556 83.032 cv with Adjusted Bootstrap Percentile (BCa) 95% CI

Confidence-interval methods for cqv

cqv accepts a method argument that selects the confidence-interval estimator. When method is omitted only the point estimate is returned (the legacy behavior).

from pycvcqv import cqv

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 ("bonett", "norm", "basic", "perc", "bca"):
    print(method, cqv(
        data=x,
        method=method,
        multiplier=100,
        ndigits=3,
        num_replicates=10000,
        random_state=42,
    ))

Output (95% CI, multiplier=100, ndigits=3, bootstrap methods use num_replicates=10000, random_state=42):

method est lower upper description
bonett 45.625 24.785 77.329 cqv with Bonett 95% CI
norm 45.625 19.937 70.403 cqv with Normal Approximation Bootstrap 95% CI
basic 45.625 21.081 73.923 cqv with Basic Bootstrap 95% CI
perc 45.625 17.327 70.169 cqv with Bootstrap Percentile 95% CI
bca 45.625 22.006 76.331 cqv with Adjusted Bootstrap Percentile (BCa) 95% CI

Credits

🚀 Your next Python package needs a bleeding-edge project structure. This project was generated with python-package-template

Metadata

Release files for pycvcqv 0.7.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pycvcqv 0.7.4
File Size Uploaded
pycvcqv-0.7.4.tar.gz 47.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pycvcqv 0.7.4
File Interpreter ABI Platform
pycvcqv-0.7.4-py3-none-any.whl Python 3 none any Details

Total release size: 126.5 kB

Release files / pycvcqv-0.7.4.tar.gz

Download URL pycvcqv-0.7.4.tar.gz
Size 47.9 kB
Tags Source
SHA-256 checksum
How to use checksums
92fe7e9d3222c71952cb961d54db91c37786defb222a5be0f27c36b786e2afe0
BLAKE2b-256 checksum
How to use checksums
bb27e30b1817fe18ed26b33eb465b9f39583b9d4ea660da0f4e6dc802b953d4f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 8, 2026.

Transparency log

Release files / pycvcqv-0.7.4-py3-none-any.whl

Download URL pycvcqv-0.7.4-py3-none-any.whl
Size 78.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e7aefbfdd18ede21a029b7346e5b432f959d8e6e57bb07219d25fc5d82427c59
BLAKE2b-256 checksum
How to use checksums
21849d3e37c9fe8258ad6a0264837eaead349d673bbdf78ca8cdd3386294accd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 8, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.7.4 This release

2 release files

0.7.3

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.2

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.18

2 release files

0.1.17

2 release files

0.1.16

2 release files

0.1.15

2 release files

0.1.14

2 release files

0.1.13

2 release files

0.1.12

2 release files

0.1.11

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page