Skip to main content

All nine Hyndman-Fan sample-quantile estimators plus pandas helpers & plots.

Project description

C2Percentiles

A lightweight, zero-dependency (core) Python package that delivers all nine Hyndman-Fan sample-quantile estimators—plus ready-made helpers for multi-column, group-wise, and visual work-flows.

PyPI pip install C2Percentiles

License MIT

Python ≥ 3.8


Why this package?

Standard libraries (NumPy, pandas) give you only one estimator—Type 7.
Research or regulatory work often needs Type 8 (median-unbiased) or Type 9 (normal QQ-plots).
C2Percentiles gives you all nine in a single line, plus batteries-included helpers for:

  • single vectors
  • many columns at once
  • stratification by groups
  • quick Seaborn/ Matplotlib visuals

Installation

# core only – no plotting
pip install C2Percentiles

# with plotting extras
pip install "C2Percentiles[plots]"

60-second tutorial

import numpy as np, pandas as pd, quantile_kit as qk

# any 1-D data
x = np.random.randn(100)

# all nine 0.25, 0.50, 0.75 quantiles
qk.quantile_custom(x, [0.25, 0.5, 0.75], qtype="all")
# → DataFrame indexed by probability

# only Types 7 & 8, 4 sig-digits, pretty strings
qk.quantile_custom(x, [0.1, 0.9], qtype=[7, 8], sig_digits=4)

# many columns at once
df = pd.DataFrame({"A": np.random.randn(80),
                   "B": np.random.randn(80)*50 + 100,
                   "Group": np.random.choice(["G1", "G2"], 80)})

qk.quantiles_for_vars(df, ["A", "B"], probs=[0.05, 0.5, 0.95])
# → long table: Variable | Probability | Type1 … Type9

# group-wise
qk.quantiles_by_group(df, "Group", ["A", "B"], probs=[0.25, 0.75])

# quick plot – estimator spread
qk.plot_quantile_line(df["B"], probs=[0.05, 0.5, 0.95])

API reference

Signature Description
quantile_custom(x, probs, qtype=7, sig_digits=None) core engine
quantiles_for_vars(df, vars, probs, qtype, sig_digits) multi-column
quantiles_by_group(df, group_var, num_vars, probs, qtype, sig_digits) grouped
plot_quantile_line(x, probs, …) single-variable plot
plot_qfv(df, vars, probs, …) faceted by variable
plot_qbg(df, group_var, vars, probs, …) faceted by group & variable

Full doc-strings are available via help(...) or your IDE.


Citation

If you use this package in research, please cite:

Hyndman, R. J. and Fan, Y. (1996) “Sample Quantiles in Statistical Packages”, American Statistician 50(4): 361–365.


License

MIT – see LICENSE file.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

c2percentiles-0.1.0.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

c2percentiles-0.1.0-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file c2percentiles-0.1.0.tar.gz.

File metadata

  • Download URL: c2percentiles-0.1.0.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for c2percentiles-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1e0b146d7d0762d18c5ac3153d82195821a7c162c36d42583611732b21540044
MD5 e83e818a9d82e64c7598b0a69f340c7f
BLAKE2b-256 b75d11815cdb0b404be1bfb31c4b5870c07f595ff4a7377af18f9dfe411103c6

See more details on using hashes here.

File details

Details for the file c2percentiles-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: c2percentiles-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for c2percentiles-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4ded0280e4e85686ae481247cbc8e2ba0ab36442f7cbe408e410f2928df5875c
MD5 e2c8438f10dd0db8262d514e21a90fa9
BLAKE2b-256 b9518524b420bc846149f35fdc2d983cc2607ded9c9cb70072784611d1884ab8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page