Metadata-Version: 2.5
Name: statsinference
Version: 0.1.4
Summary: Maximum-likelihood fitting of univariate distributions, AIC/BIC model selection, diagnostic plots and simulation.
Author: Your Name
License-Expression: BSD-3-Clause-Clear
License-File: LICENSE
Keywords: AIC,BIC,distribution fitting,maximum likelihood,statistics
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Mathematics
Requires-Python: >=3.9
Requires-Dist: matplotlib>=3.5
Requires-Dist: numpy>=1.22
Requires-Dist: scipy>=1.9
Provides-Extra: all
Requires-Dist: pandas; extra == 'all'
Requires-Dist: tqdm; extra == 'all'
Provides-Extra: dev
Requires-Dist: autopep8; extra == 'dev'
Requires-Dist: black; extra == 'dev'
Requires-Dist: build; extra == 'dev'
Requires-Dist: coverage; extra == 'dev'
Requires-Dist: flake8; extra == 'dev'
Requires-Dist: pdoc; extra == 'dev'
Requires-Dist: pytest; extra == 'dev'
Requires-Dist: twine; extra == 'dev'
Provides-Extra: pandas
Requires-Dist: pandas; extra == 'pandas'
Provides-Extra: progress
Requires-Dist: tqdm; extra == 'progress'
Provides-Extra: test
Requires-Dist: coverage; extra == 'test'
Requires-Dist: pytest; extra == 'test'
Description-Content-Type: text/markdown

# statsinference

Fit univariate distributions to data by maximum likelihood, pick the best one
by AIC or BIC, check the fit with fitdistrplus-style plots, and simulate from it.

## Install

### From GitHub

```bash
pip install git+https
```

### From PyPI

```bash
pip install .            # from this folder
pip install ".[all]"     # with progress bar (tqdm) and DataFrame tables (pandas)
```

## Quick start

```python
import numpy as np
from statsinference import StatsInference

x = np.random.default_rng(1).gamma(2, 1.5, size=300)

# Let it choose among every distribution whose support fits the data
si = StatsInference(x).select(criterion="aic", verbose=1, progress=True)
si.best_dist            # 'gamma'
si.estimate, si.sd      # estimates and standard errors
si.table                # ranking: loglik, AIC, BIC, delta, weight, KS
si.summary()            # estimates, loglik, AIC/BIC, KS / CvM / AD
si.plot()               # density, CDF, Q-Q and P-P panels
si.plot_compare(top=3)  # the three best overlaid

sims = si.simulate(1000, seed=123)              # draws from the best fit
alt  = si.simulate(1000, seed=123, dist="weibull")  # or from another candidate

# Or fit one distribution directly
StatsInference(x).fit("weibull").summary()
```

## Supported distributions

Named (case-insensitive, parameter names as in R): `beta`, `cauchy`,
`chi-squared`, `exponential`, `f`, `gamma` (shape, rate), `geometric`,
`logistic`, `lognormal` / `log-normal`, `negative binomial` (size, mu),
`normal` (closed form), `poisson`, `t` (location-scale: m, s, df), `weibull`.

Also accepted by `fit()` and `select()`:

- any SciPy distribution, e.g. `scipy.stats.genextreme`;
- your own density `f(x, **params)`, optionally with a `log` argument
  (pass `start=`).

## Main options

| Method | Arguments |
|---|---|
| `fit(densfun, start, fixed, lower, upper, method)` | `fixed` holds parameters not estimated, e.g. `fixed={"df": 5}` |
| `select(distributions, criterion, verbose, progress, options)` | `verbose`: 0 silent, 1 ranking, 2 each fit; `options={"t": {"fixed": {"df": 5}}}` |
| `simulate(size, seed, dist)` | `dist` picks another stored fit |
| `compare()`, `gof()`, `plot()`, `denscomp()`, `cdfcomp()`, `qqcomp()`, `ppcomp()` | |

Notes:

- With non-negative whole numbers, `select()` compares only count
  distributions (Poisson, geometric, negative binomial); count and
  continuous likelihoods cannot be compared by AIC. Pass `distributions=`
  to override.
- KS p-values treat the parameters as known, so they are optimistic when the
  parameters were estimated from the same data.

## Development

```bash
make help          # list every target
make install       # editable install with extras (uses uv if present, needs an active venv)
make test          # run the tests
make run-tests     # install, then tests with coverage
make lint          # flake8
make format        # black + autopep8, line length 80
make run-examples  # run everything in examples/
make docs          # API docs with pdoc, in statsinference-docs/
make check-dist    # build sdist + wheel and check them with twine
make release       # upload to PyPI
```

## License

BSD 3-Clause Clear License; see [LICENSE](LICENSE).
