fitcdf
Python library for domain-agnostic tabular analysis and univariate probability distribution fitting.
fitcdf fits continuous and discrete probability distributions to tabular columns or in-memory numeric samples, computes goodness-of-fit diagnostics, ranks candidates separately by data nature (continuous vs. discrete) and estimation method, and persists Markdown reports, JSON payloads, CSV tables, and high-resolution PNG diagnostic figures. Every distribution, estimator, diagnostic, and ranking rule is implemented directly in fitcdf's self-contained statistical core.
Contents
- Installation
- Quickstart & Python API
- Generated Outputs Reference
- Case Study 1: NIST Simulated Weibull (
RANDWEIB.DAT) - Case Study 2: NIST Simulated Lognormal (
LGN2.DAT) - Case Study 3: Synthetic Known Normal (
Normal(loc=10.0, scale=2.5)) - Supported Families (56 Distributions)
- Estimation Methods & Diagnostics
- References
Installation
Requires Python 3.11+ with lightweight scientific dependencies (numpy, scipy, matplotlib, and threadpoolctl).
pip install fitcdf
Verify the installation:
python -c "import fitcdf; print(fitcdf.__version__, fitcdf.catalog_snapshot()['total_families'])"
Quickstart & Python API
fitcdf works directly on your own CSV files, directories of CSV files, or in-memory numeric arrays:
- Input path: pass either a direct CSV path (
"path/to/data.csv") or a directory path ("path/to/folder") with optionalfile_name="data.csv"when the folder contains multiple CSV files. - Target columns: declare the numeric columns to evaluate explicitly via
columns=["col_a", "col_b"]. Column names never trigger domain-specific assumptions, and missing or non-finite rows are never silently dropped. - Output directory: pass
results_dir="path/to/output"to choose where artifacts are saved. Whenresults_diris omitted (andsave_artifacts=True, the default),fitcdfautomatically creates<cwd>/fit_results_<dataset_name>/and writes each run into a unique timestamped subfolder so previous runs are never overwritten. - Ranking metrics: by default candidates are ranked by
aic. Passmetricsto rank by any single metric ("aic","aicc","bic","ks","cvm","ad","chi_square"), a custom subset (e.g.,["aic", "ks", "ad"]), or"all"for rank-based consensus across all evaluable metrics. - Parallelism: protect script entry points with
if __name__ == "__main__":whenever settingworkers > 1.
from pathlib import Path
from fitcdf import (
analyze_dataset,
catalog_snapshot,
compare_distributions,
plot_distributions,
)
def main() -> None:
# 1. Inspect the 56-family distribution catalog
snapshot = catalog_snapshot()
print(
f"Catalog {snapshot['catalog_version']}: "
f"{snapshot['total_families']} families "
f"({snapshot['continuous_count']} continuous, {snapshot['discrete_count']} discrete)"
)
# 2. Analyze a CSV file or folder without results_dir
# Outputs are written automatically to ./fit_results_<dataset_name>/
default_report = analyze_dataset(
"path/to/measurements.csv", # or a folder path with file_name="measurements.csv"
columns=["duration_ms"],
families=["weibull_min", "lognorm", "gamma", "norm"],
data_type="continuous",
method="mle",
criterion="aic",
seed=20261028,
workers=1,
)
winner_column = default_report["columns"]["duration_ms"]
if winner_column["status"] == "analyzed":
winner = winner_column["comparison"]["rankings"][0]["fits"][0]
print(f"Rank-1 model: {winner['family']} | AIC={winner['aic']:.4f}")
print(f"Run folder : {default_report['artifacts']['directory']}")
print(f"Column files: {default_report['artifacts']['features']['duration_ms']}")
else:
# Columns with missing/non-finite rows or constant values do not raise;
# inspect status ("invalid_data", "constant", "insufficient", "non_numeric", etc.)
print(f"Skipped column ({winner_column['status']}): {winner_column.get('reason')}")
# 3. Analyze with a custom results_dir
custom_report = analyze_dataset(
"path/to/folder",
file_name="measurements.csv",
columns=["duration_ms"],
results_dir=Path("my_fit_outputs"),
families=["weibull_min", "lognorm", "gamma", "norm"],
data_type="continuous",
method="mle",
criterion="aic",
workers=1,
)
print(f"Custom output: {custom_report['artifacts']['directory']}")
# 4. Fit an in-memory sample and render selective comparison plots
sample_values = [0.42, 0.78, 1.15, 1.64, 2.09, 2.88, 3.74, 5.19, 6.41, 8.07]
comparison = compare_distributions(
sample_values,
families=["lognorm", "gamma", "norm"],
data_type="continuous",
method="mle",
criterion="aic",
workers=1,
)
plot_output = plot_distributions(
sample_values,
"in_memory_sample",
comparison,
comparison["attempts"],
results_dir=Path("my_fit_outputs"),
image_format="png",
)
print(f"Selective plots written to: {plot_output['directory']}")
# 5. Rank by a single discrepancy metric, a custom subset, or all metrics (rank consensus)
ks_comparison = compare_distributions(
sample_values,
families=["lognorm", "gamma", "norm"],
data_type="continuous",
method="mle",
metrics="ks",
workers=1,
)
subset_comparison = compare_distributions(
sample_values,
families=["lognorm", "gamma", "norm"],
data_type="continuous",
method="mle",
metrics=["aic", "ks", "ad"],
workers=1,
)
consensus_report = analyze_dataset(
"path/to/measurements.csv",
columns=["duration_ms"],
families=["weibull_min", "lognorm", "gamma", "norm"],
data_type="continuous",
method="mle",
metrics="all",
workers=1,
)
consensus_group = consensus_report["columns"]["duration_ms"]["comparison"]["rankings"][0]
consensus_winner = consensus_group["fits"][0]
print(
f"Consensus rank-1: {consensus_winner['family']} | "
f"mean rank={consensus_winner['mean_rank']:.2f} "
f"({consensus_winner['evaluated_metric_count']}/{consensus_winner['expected_metric_count']})"
)
# 6. Direct closed-form inference, adequacy, quantiles, and percentile bootstrap
from fitcdf import (
estimate_parameters,
evaluate_model_adequacy,
predict_quantiles,
resample_parameter_uncertainty,
)
fitted_model = estimate_parameters(sample_values, "norm", criterion="likelihood")
adequacy = evaluate_model_adequacy(sample_values, fitted_model)
quantiles = predict_quantiles(fitted_model, [0.1, 0.5, 0.9])
uncertainty = resample_parameter_uncertainty(
sample_values, "norm", "likelihood", repetitions=100, seed=20261028
)
print(f"KS={adequacy['kolmogorov_distance']:.4f} | Q50={quantiles['0.5']:.4f}")
print(f"95% bootstrap intervals: {uncertainty['intervals']}")
if __name__ == "__main__":
main()
A complete runnable example script (examples/use_library.py) is available in the GitHub repository (not bundled inside the installed PyPI wheel). Clone or download it to run from the command line:
python examples/use_library.py
python examples/use_library.py --metrics ks
python examples/use_library.py --metrics aic ks ad
python examples/use_library.py --metrics all
python examples/use_library.py --input path/to/measurements.csv --column duration_ms --metrics all
Public API Overview
| Function | Purpose | Primary Arguments | Return Value |
|---|---|---|---|
analyze_dataset |
End-to-end CSV loading, fitting, ranking, and artifact persistence | path, columns, file_name, results_dir, families, data_type, method, criterion, metrics |
Dict with per-column status ("analyzed", "invalid_data", "constant", "insufficient", "non_numeric", "no_eligible_fit"), "comparison" (present when "analyzed"), and "artifacts" (directory, manifest, features[col]) |
compare_distributions |
In-memory univariate fitting, diagnostics, and ranking | observations, families, data_type, method, criterion, metrics, workers, gof_replicates, bounds |
Comparison dict (attempts, rankings, configuration) |
plot_distributions |
Selective multi-family PDF/PMF, CDF, and combined panel rendering | observations, feature_name, comparison_or_type, attempts_or_families, results_dir, image_format |
Dict with root keys directory, files (pdf, cdf, pdf_cdf, parameters, plot), plotted, failed, ks_analysis, success |
catalog_snapshot / list_available_families / get_distribution |
Inspect catalog metadata, parameter semantics, and frozen evaluators | Optional data_type or family identifier |
Catalog metadata dict, family specs, or distribution instance |
estimate_parameters |
Direct closed-form estimation for norm/normal, expon/exponential, lognorm/lognormal |
observations, family, criterion ("likelihood" or "moments") |
InferenceResult dataclass (family, parameters, log_likelihood, information_aic, information_bic) |
evaluate_model_adequacy |
One-sample Kolmogorov distance for a fitted InferenceResult |
observations, model (InferenceResult) |
Dict (kolmogorov_distance, p_value, note) |
predict_quantiles |
Evaluate theoretical quantiles for a fitted InferenceResult |
model (InferenceResult), probabilities (strictly in (0, 1)) |
Dict mapping probability strings to quantile values |
resample_parameter_uncertainty |
Nonparametric percentile bootstrap 95% intervals for norm/expon/lognorm |
observations, family, criterion, repetitions (>= 20), seed |
Dict (intervals, valid_repetitions, failed_repetitions, confidence_level) |
Generated Outputs Reference
Every call to analyze_dataset(..., save_artifacts=True) writes a self-contained, non-overwriting run directory:
fit_results_<dataset_name>/ # Default <cwd> destination (or custom results_dir)
└── 20261130T124530-a1b2c3d4e5f6/ # Unique UTC timestamp + run identifier
├── manifest.json # Run-level metadata, input profile, and feature paths
└── <column_name>-<hash>/ # Isolated folder per analyzed column
├── report.md # Technical Markdown report with rankings and plot links
├── result.json # Machine-readable JSON payload with parameter metadata
├── results.csv # Semicolon-delimited table across all fitted candidates
├── density.png # Histogram / empirical PMF vs. top fitted curves + rug
├── cumulative.png # Empirical CDF + 95% DKW band + KS marker + residual panel
├── quantiles.png # Quantile-Quantile (Q-Q) diagnostic plot with 1:1 identity and quartiles
├── probabilities.png # Classical P-P plot (with DKW guide) and detrended P-P plot
├── survival.png # Log-scale empirical vs. theoretical survival curve S(x)
├── pdf.png # Standalone comparative PDF / PMF panel
├── cdf.png # Standalone comparative CDF and residual panel
└── models/ # Isolated folders for the winner and close alternatives
└── <method>/ # mle, moments, quantiles, distance, or spacings
└── <data_type>/ # continuous or discrete
└── 01_<winner_family>/ # Rank-prefixed model directory
├── pdf.png # Individual PDF / PMF plot for this model alone
├── cdf.png # Individual CDF + max KS marker for this model alone
└── report.md # Parameter estimates, bounds, meanings, and selection record
manifest.json: Top-level index mapping each analyzed column to its output directory and recording dataset profiling details.report.md: Human-readable summary containing sample statistics, primary rankings (single metric or rank-based consensus), individual per-metric ranking tables and unavailable-metric notes when multiple metrics are selected, parameter interpretations, and links to all diagnostic plots.result.json: Structured payload suitable for downstream pipelines, containing fitted parameters, bounds, convergence statuses, per-metric rankings, and goodness-of-fit diagnostics.results.csv: Semicolon-delimited (;) flat table with one row per candidate attempt, including criterion scores, $\Delta$, Akaike weights, log-likelihood, parameter counts, KS, CvM, AD, $\chi^2$, optimizer evaluations, duration, and additive consensus columns (evaluated_metrics,missing_metrics,mean_rank,first_place_count, populated in multi-metric consensus mode).- 7 Feature-Level Diagnostic Plots: Full-width comparative visuals (
density.png,cumulative.png,quantiles.png,probabilities.png,survival.png,pdf.png,cdf.png) rendered at publication resolution with the colorblind-safe Okabe–Ito palette. - Individual Model Plots (
models/<method>/<data_type>/): Dedicated single-modelpdf.png,cdf.png, andreport.mdfiles for the rank-1 winner and any qualifying close alternatives.
Case Study 1: NIST Simulated Weibull (RANDWEIB.DAT)
This example fits 10 continuous distributions via Maximum Likelihood Estimation (mle) to the public NIST/SEMATECH simulated Weibull sample (RANDWEIB.DAT, column valor, n = 500, generated from Weibull(c = 2, loc = 0, scale = 1)).
Runnable Code
from fitcdf import analyze_dataset
report = analyze_dataset(
"dataset/nist_weibull_simulada/dados.csv", # Replace with your own CSV path
columns=["valor"],
data_type="continuous",
families=[
"weibull_min",
"weibull_2p_left_trunc",
"gamma",
"lognorm",
"norm",
"expon",
"fatiguelife",
"burr12",
"fisk",
"rayleigh",
],
method="mle",
criterion="aic",
seed=20261028,
workers=1,
)
Sample Summary & Observed Ranking
| Column | n |
Mean | Median | Std. Dev. | Min | Q1 | Q3 | Max |
|---|---|---|---|---|---|---|---|---|
valor |
500 |
0.8991 |
0.8423 |
0.4487 |
0.005674 |
0.5749 |
1.1996 |
2.3209 |
| Rank | Family | AIC | $\Delta\text{AIC}$ | Akaike Weight | BIC | KS ($D$) | CvM ($W^2$) | Free Params | Estimated Parameters |
|---|---|---|---|---|---|---|---|---|---|
| 1 | rayleigh |
584.76 | 0.00 | 40.5% | 588.97 | 0.0311 | 0.0874 | 1 | loc=0.0, scale=0.7104 |
| 2 | weibull_min |
585.03 | 0.27 | 35.4% | 593.45 | 0.0234 | 0.0301 | 2 | c=2.0962, loc=0.0, scale=1.0138 |
| 3 | weibull_2p_left_trunc |
587.01 | 2.25 | 13.2% | 599.65 | 0.0234 | 0.0301 | 3 | c=2.0959, trunc_left=0.005674, scale=1.0138 |
| 4 | burr12 |
587.38 | 2.62 | 10.9% | 600.02 | 0.0242 | 0.0321 | 3 | c=2.1075, d=100.0, scale=8.9848 |
| 5 | gamma |
613.51 | 28.76 | <0.1% | 621.94 | 0.0514 | 0.3076 | 2 | a=3.2757, loc=0.0, scale=0.2745 |
| 6 | norm |
620.45 | 35.69 | <0.1% | 628.87 | 0.0586 | 0.3543 | 2 | loc=0.8991, scale=0.4482 |
| 7 | fisk |
662.01 | 77.26 | <0.1% | 670.44 | 0.0597 | 0.3809 | 2 | c=2.9506, loc=0.0, scale=0.8146 |
| 8 | lognorm |
717.57 | 132.81 | <0.1% | 726.00 | 0.0810 | 1.2233 | 2 | s=0.6449, loc=0.0, scale=0.7659 |
| 9 | expon |
895.60 | 310.84 | <0.1% | 899.81 | 0.2303 | 10.0066 | 1 | loc=0.0, scale=0.8991 |
| 10 | fatiguelife |
907.96 | 323.21 | <0.1% | 916.39 | 0.1844 | 5.9224 | 2 | c=0.8203, loc=0.0, scale=0.6598 |
Rank-1 Parameter Summary (models/mle/continuous/01_rayleigh/report.md)
| Parameter | Estimate | Status | Search Bounds | Statistical Meaning |
|---|---|---|---|---|
loc |
0 |
fixed | [0; 0] |
Lower support endpoint of the Rayleigh distribution. |
scale |
0.7103543 |
free | [2.3151936e-06; 232.0868] |
Mode displacement above loc; positive dispersion parameter. |
Real results.csv Excerpt (Top 4 Rows)
rank;distribution_name;family;data_type;method;status;eligible;criterion;score;delta;akaike_weight;log_likelihood;parameter_count;aic;aicc;bic;ks;cvm;ad;chi2;evaluations;duration_seconds;parameters;reason
1;Rayleigh;rayleigh;continuous;mle;fitted;True;aic;584.7570277186096;0.0;0.4049762751371152;-291.3785138593048;1;584.7570277186096;584.7650598471237;588.9716358170318;0.031109701822733538;0.08743169138912257;0.5313783421218545;6.559999999999915;0;0.0021931009978288785;loc=0.0, scale=0.7103542983076149;Exact closed-form maximum likelihood solution.
2;Weibull Minimum;weibull_min;continuous;mle;fitted;True;aic;585.0251501227347;0.2681224041250516;0.35416655024832133;-290.51257506136733;2;585.0251501227347;585.04929499195;593.4543663195791;0.02340824250555862;0.030112355367573698;0.19779221722586726;7.920000000000018;405;0.04097736600670032;c=2.0961920780987904, loc=0.0, scale=1.0138095496123853;Numerical convergence confirmed by the optimizer.
3;2-Parameter Left-Truncated Weibull;weibull_2p_left_trunc;continuous;mle;fitted;True;aic;587.0061115081867;2.249083789577071;0.1315367908341654;-290.50305575409334;3;587.0061115081867;587.0544986049608;599.6499358034532;0.02343063532686529;0.030122325421878135;1.5577151409848398;7.920000000000035;669;0.04609012899163645;c=2.095911618449196, trunc_left=0.005674428, loc=0.0, scale=1.013773666148315;Numerical convergence confirmed by the optimizer.
4;Burr Type XII;burr12;continuous;mle;fitted;True;aic;587.3761232986986;2.619095580089038;0.10932014587429213;-290.6880616493493;3;587.3761232986986;587.4245103954728;600.0199475939652;0.02415898959163154;0.03213892841615452;0.21297891374877054;7.919999999999765;1458;0.14107553799112793;c=2.107455896579404, d=100.0, loc=0.0, scale=8.984801503325652;Numerical convergence confirmed by the optimizer.
Diagnostic Figures — NIST Simulated Weibull
Comparative Density (density.png)
Freedman–Diaconis histogram and marginal rug overlaid with the top five fitted densities; the Weibull/Rayleigh cluster matches both the mode near 0.7 and the right-skewed decay, while gamma shifts the peak too far left.
Empirical CDF & Residual Deviation (cumulative.png)
Empirical step CDF with its 95% Dvoretzky–Kiefer–Wolfowitz (DKW) simultaneous band, maximum KS distance callout (D_KS = 0.0234 for weibull_min), and bottom residual panel $F_n(x) - \hat{F}(x)$ staying well inside the confidence limits.
Quantile-Quantile Diagnostic (quantiles.png)
Quantile-Quantile (Q-Q) plot with 1:1 identity reference and sample quartile guides confirming close agreement in original units across the lower and upper tails for the top four models.
Probability-Probability & Detrended P-P Plot (probabilities.png)
Classical P-P plot with the 95% DKW band (left) and detrended P-P residuals (right), highlighting central probability-mass agreement and exposing the S-shaped misfit of gamma.
Log-Scale Survival Function (survival.png)
Log-scale empirical survival curve $S(x) = 1 - F(x)$ with upper-tail reference percentiles ($P_{90}, P_{95}, P_{99}$) separating Weibull-like tail decay from heavier-tailed alternatives.
Standalone Comparative PDF (pdf.png)
Standalone comparative PDF panel formatted for direct inclusion in reports and slides.
Standalone Comparative CDF (cdf.png)
Standalone comparative CDF and residual deviation panel isolating the top candidates.
Rank-1 Model PDF (models/mle/continuous/01_rayleigh/pdf.png)
Dedicated single-model density plot for the rank-1 AIC winner (rayleigh) without competing curves.
Rank-1 Model CDF (models/mle/continuous/01_rayleigh/cdf.png)
Dedicated single-model CDF plot for rayleigh pinning its maximum Kolmogorov–Smirnov discrepancy coordinate (D_KS = 0.0311).
Case Study 2: NIST Simulated Lognormal (LGN2.DAT)
This example fits 10 continuous distributions via Maximum Likelihood Estimation (mle) to the public NIST/Dataplot simulated lognormal sample (LGN2.DAT, Olsson 2005, column valor, n = 40, generated from Lognormal(s = 1, loc = 0, scale = exp(5) ≈ 148.413)).
Runnable Code
from fitcdf import analyze_dataset
report = analyze_dataset(
"dataset/nist_lognormal/dados.csv", # Replace with your own CSV path
columns=["valor"],
data_type="continuous",
families=[
"lognorm",
"gamma",
"weibull_min",
"weibull_2p_left_trunc",
"invgauss",
"fisk",
"burr12",
"norm",
"expon",
"fatiguelife",
],
method="mle",
criterion="aic",
seed=20261028,
workers=1,
)
Sample Summary & Observed Ranking
| Column | n |
Mean | Median | Std. Dev. | Min | Q1 | Q3 | Max |
|---|---|---|---|---|---|---|---|---|
valor |
40 |
274.96 |
177.35 |
310.34 |
23.80 |
79.93 |
338.05 |
1568.30 |
| Rank | Family | AIC | $\Delta\text{AIC}$ | Akaike Weight | BIC | KS ($D$) | CvM ($W^2$) | Free Params | Estimated Parameters |
|---|---|---|---|---|---|---|---|---|---|
| 1 | invgauss |
525.59 | 0.00 | 28.2% | 528.97 | 0.0858 | 0.0193 | 2 | mu=1.5478, loc=0.0, scale=177.6427 |
| 2 | fatiguelife |
525.67 | 0.08 | 27.0% | 529.05 | 0.0610 | 0.0219 | 2 | c=1.0920, loc=0.0, scale=173.2223 |
| 3 | weibull_2p_left_trunc |
526.10 | 0.51 | 21.8% | 531.17 | 0.0579 | 0.0162 | 3 | c=0.7807, trunc_left=23.8, scale=198.1872 |
| 4 | lognorm |
527.03 | 1.44 | 13.7% | 530.41 | 0.0677 | 0.0246 | 2 | s=0.9917, loc=0.0, scale=168.5438 |
| 5 | fisk |
529.19 | 3.61 | 4.6% | 532.57 | 0.0781 | 0.0316 | 2 | c=1.7133, loc=0.0, scale=165.8174 |
| 6 | burr12 |
531.19 | 5.60 | 1.7% | 536.26 | 0.0805 | 0.0319 | 3 | c=1.7456, d=0.9490, scale=158.1327 |
| 7 | expon |
531.33 | 5.74 | 1.6% | 533.02 | 0.1053 | 0.0733 | 1 | loc=0.0, scale=274.9625 |
| 8 | gamma |
532.80 | 7.21 | 0.8% | 536.18 | 0.1124 | 0.1017 | 2 | a=1.1599, loc=0.0, scale=237.0655 |
| 9 | weibull_min |
533.28 | 7.69 | 0.6% | 536.65 | 0.1031 | 0.0812 | 2 | c=1.0274, loc=0.0, scale=278.4518 |
| 10 | norm |
575.52 | 49.93 | <0.1% | 578.89 | 0.2189 | 0.5933 | 2 | loc=274.9625, scale=306.4389 |
Rank-1 Parameter Summary (models/mle/continuous/01_invgauss/report.md)
| Parameter | Estimate | Status | Search Bounds | Statistical Meaning |
|---|---|---|---|---|
mu |
1.5478401 |
free | [0.0001; 6273.2] |
Standardized mean-to-shape ratio of the Inverse Gaussian (Wald) distribution. |
loc |
0 |
fixed | [0; 0] |
Lower support endpoint of the Inverse Gaussian distribution. |
scale |
177.6427 |
free | [0.0015445; 156830] |
Positive scale factor of the Inverse Gaussian distribution. |
Real results.csv Excerpt (Top 4 Rows)
rank;distribution_name;family;data_type;method;status;eligible;criterion;score;delta;akaike_weight;log_likelihood;parameter_count;aic;aicc;bic;ks;cvm;ad;chi2;evaluations;duration_seconds;parameters;reason
1;Inverse Gaussian;invgauss;continuous;mle;fitted;True;aic;525.587579571478;0.0;0.281615132825007;-260.793789785739;2;525.587579571478;525.9119038958024;528.9653384797059;0.0857928449905816;0.019325336877722508;0.12980804659098055;1.0999999999999972;649;0.04872052698920015;mu=1.5478401294347972, loc=0.0, scale=177.64269747856298;Numerical convergence confirmed by the optimizer.
2;Birnbaum-Saunders;fatiguelife;continuous;mle;fitted;True;aic;525.6712394777719;0.08365990629386033;0.2700781626548883;-260.83561973888595;2;525.6712394777719;525.9955638020963;529.0489983859998;0.061028145087960506;0.021900516414203125;0.1485640466166629;0.6999999999999961;637;0.049209962991881184;c=1.0919892124173214, loc=0.0, scale=173.2222846123733;Numerical convergence confirmed by the optimizer.
3;2-Parameter Left-Truncated Weibull;weibull_2p_left_trunc;continuous;mle;fitted;True;aic;526.0990082435392;0.511428672061129;0.21807237989157402;-260.0495041217696;3;526.0990082435392;526.7656749102058;531.165646605881;0.057903963432267884;0.016208052157442896;17.264997779385723;0.39999999999999925;1407;0.074415669994778;c=0.7807077710381518, trunc_left=23.8, loc=0.0, scale=198.18722777915838;Numerical convergence confirmed by the optimizer.
4;Log-Normal;lognorm;continuous;mle;fitted;True;aic;527.0274462333102;1.439866661832184;0.13708594030444526;-261.5137231166551;2;527.0274462333102;527.3517705576346;530.4052051415381;0.06768268971202862;0.024570591241194983;0.17380927349144315;1.5999999999999992;0;0.002779629998258315;s=0.99174327413845, loc=0.0, scale=168.5437813704128;Exact closed-form maximum likelihood solution.
Diagnostic Figures — NIST Simulated Lognormal
Comparative Density (density.png)
Right-skewed empirical histogram (skewness = 2.34, excess kurtosis = 6.14) overlaid with the top five skewed candidates, capturing both the sharp lower concentration and the long right tail up to 1568.3.
Empirical CDF & Residual Deviation (cumulative.png)
Step ECDF with its wider small-sample 95% DKW confidence band ($\pm 0.215$), showing all top five skewed models staying close to the zero-residual line (D_KS = 0.0579 for weibull_2p_left_trunc, 0.0677 for lognorm).
Quantile-Quantile Diagnostic (quantiles.png)
Quantile-Quantile (Q-Q) plot revealing how invgauss, fatiguelife, weibull_2p_left_trunc, and lognorm track the upper-tail order statistics above 800.
Probability-Probability & Detrended P-P Plot (probabilities.png)
Classical and detrended P-P panels confirming tight calibration across the full cumulative probability range [0, 1] inside the 95% DKW envelope.
Log-Scale Survival Function (survival.png)
Log-scale survival trajectories highlighting upper-tail behavior past $P_{90}$, $P_{95}$, and $P_{99}$, where lognorm, invgauss, and fatiguelife closely bound the extreme observations.
Standalone Comparative PDF (pdf.png)
Standalone comparative PDF panel summarizing the five highest-ranked skewed candidates.
Standalone Comparative CDF (cdf.png)
Standalone comparative CDF and residual deviation panel for the Lognormal case study.
Rank-1 Model PDF (models/mle/continuous/01_invgauss/pdf.png)
Dedicated single-model density plot for the rank-1 AIC candidate (invgauss) showing its fit across the heavy right tail.
Rank-1 Model CDF (models/mle/continuous/01_invgauss/cdf.png)
Dedicated single-model CDF plot for invgauss highlighting its maximum Kolmogorov–Smirnov discrepancy (D_KS = 0.0858).
Case Study 3: Synthetic Known Normal (Normal(loc=10.0, scale=2.5))
This self-contained example generates a reproducible sample from a known distribution (Normal(loc = 10.0, scale = 2.5), n = 500, seed = 20261028), writes it to a temporary CSV file, and evaluates six competing continuous families via Maximum Likelihood Estimation (mle).
Runnable Code
import tempfile
from pathlib import Path
import numpy as np
from fitcdf import analyze_dataset
rng = np.random.default_rng(20261028)
values = rng.normal(loc=10.0, scale=2.5, size=500)
with tempfile.TemporaryDirectory() as tmp_dir:
csv_path = Path(tmp_dir) / "synthetic_normal.csv"
csv_path.write_text(
"measurement\n" + "\n".join(f"{val:.6f}" for val in values) + "\n",
encoding="utf-8",
)
report = analyze_dataset(
csv_path,
columns=["measurement"],
families=["norm", "t", "logistic", "laplace", "gumbel_r", "uniform"],
data_type="continuous",
method="mle",
criterion="aic",
seed=20261028,
workers=1,
)
col = report["columns"]["measurement"]
if col["status"] == "analyzed":
for fit in col["comparison"]["rankings"][0]["fits"]:
print(
f"#{fit['rank']} {fit['family']:<10} "
f"AIC={fit['aic']:.2f} BIC={fit['bic']:.2f} "
f"KS={fit['diagnostics']['ks']['statistic']:.4f}"
)
Sample Summary & Observed Ranking
| Column | n |
Mean | Median | Std. Dev. | Min | Q1 | Q3 | Max |
|---|---|---|---|---|---|---|---|---|
measurement |
500 |
10.1003 |
9.9429 |
2.4715 |
2.0358 |
8.4588 |
11.7948 |
18.7115 |
| Rank | Family | AIC | $\Delta\text{AIC}$ | Akaike Weight | BIC | KS ($D$) | CvM ($W^2$) | Free Params | Estimated Parameters |
|---|---|---|---|---|---|---|---|---|---|
| 1 | t |
2325.56 | 0.00 | 50.4% | 2338.21 | 0.0295 | 0.0560 | 3 | df=16.3954, loc=10.0792, scale=2.3135 |
| 2 | norm |
2326.75 | 1.19 | 27.8% | 2335.18 | 0.0309 | 0.0587 | 2 | loc=10.1003, scale=2.4690 |
| 3 | logistic |
2327.24 | 1.68 | 21.8% | 2335.67 | 0.0307 | 0.1008 | 2 | loc=10.0640, scale=1.3945 |
| 4 | laplace |
2368.26 | 42.70 | <0.1% | 2376.69 | 0.0691 | 0.5531 | 2 | loc=9.9429, scale=1.9564 |
| 5 | gumbel_r |
2393.04 | 67.48 | <0.1% | 2401.47 | 0.0709 | 0.7341 | 2 | loc=8.8841, scale=2.4332 |
| 6 | uniform |
2817.96 | 492.39 | <0.1% | 2826.38 | 0.2453 | 11.3885 | 2 | loc=2.0358, scale=16.6757 |
Diagnostic Figures — Synthetic Known Normal
Comparative Density (density.png)
Histogram and marginal rug overlaid with the top five symmetric and skewed candidates; norm, t, and logistic track the bell-shaped bulk closely while laplace over-peaks at the center.
Empirical CDF & Residual Deviation (cumulative.png)
Empirical step CDF with its 95% DKW confidence band and bottom residual panel confirming tight uniform agreement (D_KS = 0.0309 for norm).
Supported Families (56 Distributions)
fitcdf ships a versioned catalog of 56 univariate distributions (44 continuous and 12 discrete), organized by mathematical support and data nature:
| Category | Count | Families |
|---|---|---|
| Standard Continuous | 40 | anglit, beta, burr12, cauchy, chi2, cosine, crystalball, erlang, expon, exponnorm, f, fatiguelife, fisk, gamma, genextreme, gennorm, genpareto, gompertz, gumbel_l, gumbel_r, halfcauchy, halfnorm, invgamma, invgauss, laplace, logistic, lognorm, lomax, maxwell, nakagami, norm, pareto, rayleigh, skewnorm, t, triang, tukeylambda, uniform, weibull_max, weibull_min |
| Truncated Weibull | 4 | weibull_2p_left_trunc, weibull_2p_right_trunc, weibull_3p_left_trunc, weibull_3p_right_trunc |
| Standard Discrete | 11 | bernoulli, betabinom, binom, geom, hypergeom, logser, nbinom, planck, poisson, randint, zipf |
| Poisson-Binomial | 1 | poisson_binomial (evaluated when trial probabilities or trial counts are supplied explicitly) |
Estimation Methods & Diagnostics
Five Estimation Methods
| Method | Identifier | Applicability | Description |
|---|---|---|---|
| Maximum Likelihood | mle |
Continuous & Discrete | Closed-form analytic MLE where available; bounded multi-start numerical log-likelihood maximization and discrete integer profile/coordinate ascent otherwise. |
| Method of Moments | moments |
Continuous only (excludes cauchy, halfcauchy) |
Matches theoretical moments (mean, variance, skewness, kurtosis) to empirical sample moments. Returns method_unavailable on discrete families and families without finite moments. |
| Quantile Matching | quantiles |
Continuous only | Minimizes squared discrepancies between empirical and theoretical quantiles across symmetric probability grids. Returns method_unavailable on discrete families. |
| Minimum Distance | distance |
Continuous only | Minimizes empirical-to-theoretical CDF distance (Cramér–von Mises / Kolmogorov objectives). Returns method_unavailable on discrete families. |
| Maximum Product of Spacings | spacings |
Continuous only (no ties) | Maximizes the geometric mean of CDF spacings between ordered continuous observations (Cheng & Amin). Returns incompatible on discrete families or samples with ties. |
Goodness-of-Fit & Uncertainty Diagnostics
- Information Criteria & Relative Support:
AIC,AICc,BIC, $\Delta_i$, and relative Akaike weights $w_i$ computed strictly within compatible data-nature and estimation-method groups. - Empirical Distribution Discrepancies: Kolmogorov–Smirnov ($D$), Cramér–von Mises ($W^2$), Anderson–Darling ($A^2$), and binned Pearson Chi-Square ($\chi^2$).
- Multi-Metric Rank Consensus: When multiple metrics (or
metrics="all") are requested,fitcdfranks each evaluable metric independently and aggregates ordinal positions into a deterministic rank-based consensus (prioritizing complete coverage and listing any missing or unavailable metrics explicitly without combining incompatible raw scales). - Simultaneous Confidence Envelope: 95% Dvoretzky–Kiefer–Wolfowitz (DKW) band on ECDF and P-P diagnostic plots.
- Bootstrap Calibration & Uncertainty: Passing
gof_replicates > 0runs parametric goodness-of-fit bootstrap with refitting in each replicate and stores calibrated p-values underattempt["diagnostics"]["bootstrap"](ks_p_value,cvm_p_value,ad_p_value,valid_replicates). Nonparametric percentile bootstrap intervals are available viaresample_parameter_uncertainty.
References
The probability definitions, parameterizations, estimation procedures, and diagnostic conventions in fitcdf are grounded in:
- Balakrishnan, N., & Nevzorov, V. B. (2003). A Primer on Statistical Distributions. Wiley-Interscience.
- Thomopoulos, N. T. (2017). Statistical Distributions: Applications and Parameter Estimates. Springer International Publishing.
- NIST/SEMATECH (2012). e-Handbook of Statistical Methods. National Institute of Standards and Technology (source of the
RANDWEIB.DATandLGN2.DATbenchmark samples). - Additional bibliographic references on information criteria, goodness-of-fit diagnostics, and model selection are included inside each generated feature
report.md.
Metadata
Release files for fitcdf 0.6.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fitcdf-0.6.4.tar.gz | 154.1 kB | With provenance | Details for fitcdf-0.6.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fitcdf-0.6.4-py3-none-any.whl | Python 3 | none | any | Details for fitcdf-0.6.4-py3-none-any.whl |
Total release size: 293.1 kB
Release files / fitcdf-0.6.4.tar.gz
| Download URL | fitcdf-0.6.4.tar.gz |
|---|---|
| Size | 154.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
84073f3990086f21dcd241e862f9d90d9f923cceae1d30c1916ad1010fad8b4c
|
|
BLAKE2b-256 checksum How to use checksums |
31da4d0b754c7657a4b42e710c66720e77b169303d5145a52b807333500b419b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 30, 2026.
Transparency logRelease files / fitcdf-0.6.4-py3-none-any.whl
| Download URL | fitcdf-0.6.4-py3-none-any.whl |
|---|---|
| Size | 139.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a8cec29ad213dac8d60376fb7830e98e6adc1061d164614c79d39f793dc2864e
|
|
BLAKE2b-256 checksum How to use checksums |
3956726f90408ecd72fbc900db8f42d64c33f398de5791460c01b423553568bd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 30, 2026.
Transparency logSecurity for fitcdf 0.6.4
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for fitcdf-0.6.4.tar.gz
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 Nov 30, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.