packages feed

hanalyze-core-0.2.0.1: README.md

# hanalyze-core

The **bottom layer** of [`hanalyze`](../README.md) — pure numerics with
no dataframe and no Bayesian dependency: descriptive statistics, hypothesis
tests, distributions, optimisation, and the MCMC abstractions.

It depends only on 10 external packages (`base` / `hmatrix` / `vector` /
`statistics` / `containers` / `mwc-random` and friends) and on **no other
package in this repository**. Every upper layer (`-frame` / `-bayes` /
`-models` / `-design` / `-viz`) goes through it.

## Main modules (44 in total)

### Statistics (`Hanalyze.Stat.*`)

| Module | Role |
|---|---|
| `Stat.Descriptive` | The **single source of truth** for univariate descriptive statistics (mean / variance / quantiles / skewness / kurtosis). All upper-layer aggregation delegates here |
| `Stat.Test` | Unifies the test family behind a single `TestResult` type (t / Welch / F / χ² / non-parametric / Hotelling T² one- and two-sample / one-way MANOVA) |
| `Stat.Distribution` | pdf / cdf / quantile / sampling for 40+ distributions |
| `Stat.Effect` | Effect sizes (Cohen's d / Hedges' g / η² / Cliff's δ) |
| `Stat.Bootstrap` / `Stat.CV` | Bootstrap confidence intervals / cross-validation splitters |
| `Stat.MultipleTesting` | Multiple-comparison correction (Bonferroni / Holm / BH-FDR) |
| `Stat.SPC` | Statistical process control — variable charts (X̄-R / I-MR), attribute charts (p / np / c / u) and EWMA / CUSUM, with Western Electric / Nelson rules |
| `Stat.GroupComparison` | Good-vs-bad group comparison (`goodVsBad` — ranks every variable by Welch's t-test and Cohen's d) |
| `Stat.ClassMetrics` | Classification metrics (confusion matrix / ROC-AUC / F1) |

### Optimisation (`Hanalyze.Optim.*`)

| Module | Role |
|---|---|
| `Optim.NelderMead` | Derivative-free simplex method, the default of R's `optim(method="Nelder-Mead")` |
| `Optim.LBFGS` / `Optim.GradAscent` / `Optim.Adam` | Gradient-based methods |
| `Optim.CMAES` / `Optim.DifferentialEvolution` / `Optim.ParticleSwarm` / `Optim.SimulatedAnnealing` | Global optimisation |
| `Optim.NSGA` / `Optim.Pareto` | Multi-objective optimisation — NSGA-II (Deb et al. 2002) and Pareto-front utilities |
| `Optim.Constrained` / `Optim.Desirability` | Augmented-Lagrangian constrained optimisation / desirability scalarisation (Derringer & Suich 1980) |

### Foundations (`MCMC.Core` / `Model.Core` / `Math.*`)

| Module | Role |
|---|---|
| `MCMC.Core` | Sampler-agnostic `Chain` type and posterior statistics (`posteriorMean` / `posteriorSD` / `posteriorQuantile`). The base for using `MCMC.*` as a standalone sampling library |
| `Stat.MCMC` | MCMC diagnostics — `rhat` / `ess` / `essBulk` / `hdi` / `autocorr` / `bfmi` (the samplers themselves live in `-bayes`) |
| `Model.Core` | The Result type and `Model` class shared by every regression model |
| `Math.HSIC` / `Math.ICA` / `Math.Hungarian` | HSIC independence statistic / FastICA (Hyvärinen 1999) / Hungarian assignment |

## Using it standalone

If you do not need the upper layers, depend on this package directly:

```cabal
build-depends: hanalyze-core, hmatrix
```

```haskell
import qualified Hanalyze.Stat.Test as ST
import qualified Numeric.LinearAlgebra as LA

main = do
  let xs = LA.fromList [12, 14, 13, 15, 17, 11]
      ys = LA.fromList [18, 22, 20, 19, 25, 17]
      result = ST.tTestWelch xs ys ST.TwoSided
  print (ST.trPValue result, ST.trEffect result)
  -- (1.688e-3, Just ("Cohen's d", -2.527))
```

Normally you would just depend on the umbrella package `hanalyze` and
get all of the above from a single `import Hanalyze`. Naming a layer
directly is only worth it when you want to minimise dependencies.

## Related docs

- Tests: [docs/stat/01-test.md](../docs/stat/01-test.md) /
  multivariate tests (Hotelling T² / MANOVA): [docs/stat/usage-multivariate-test.md](../docs/stat/usage-multivariate-test.md)
- Control charts and rules (SPC): [docs/stat/usage-spc.md](../docs/stat/usage-spc.md)
- Group comparison (good vs bad): [docs/stat/usage-group-comparison.md](../docs/stat/usage-group-comparison.md)
- Effect sizes: [docs/stat/09-effect.md](../docs/stat/09-effect.md) /
  bootstrap: [docs/stat/07-bootstrap.md](../docs/stat/07-bootstrap.md)
- Optimisation: [docs/optim/01-singleobj.md](../docs/optim/01-singleobj.md) /
  [docs/optim/02-multi-objective.md](../docs/optim/02-multi-objective.md)

← [repository README](../README.md)