Router
router
Intelligent statistical inference engine router.
This module provides the route_inference_engine routing function, which acts as the decision gateway
of the analysis layer. It maps the combination of metric characteristics (continuous vs ratio vs binary)
and user-selected statistical methodologies to the exact mathematical execution engine.
| FUNCTION | DESCRIPTION |
|---|---|
route_inference_engine |
Routes to the correct statistical engine based on metric and design types. |
route_inference_engine
route_inference_engine(
metric: BaseMetric, design_type: str
) -> str
Routes to the correct statistical engine based on metric and design types.
Selects the mathematically correct statistical test and variance estimator depending on the structural type of the metric (continuous mean, ratio of random variables, binary rate) and the user's desired inferential paradigm (Frequentist, Bayesian, Sequential, or Bootstrap).
Inference Routing Matrix
+------------------+-----------------------------+-----------------------------+-------------------------------+ | Metric Type | Frequentist | Bayesian | Sequential (mSPRT) | +------------------+-----------------------------+-----------------------------+-------------------------------+ | MeanMetric | Welch's t-test (CLT) | Normal-Normal Conjugate / | Continuous Normal Likelihood | | | | Gibbs Sampler | Ratio Martingale | +------------------+-----------------------------+-----------------------------+-------------------------------+ | RatioMetric | Delta Method t-test | Normal-Normal Delta / | Ratio-Delta Likelihood | | | (Taylor approximation) | MCMC Sampler | Ratio Martingale | +------------------+-----------------------------+-----------------------------+-------------------------------+ | BinaryMetric | Pearson Z-test (Wald CI) | Beta-Binomial Conjugate | Bernoulli Likelihood | | | / Fisher's Exact Test | (Exact posterior) | Ratio Martingale | +------------------+-----------------------------+-----------------------------+-------------------------------+
Pseudocode for Routing Logic
function route_inference_engine(metric, paradigm):
1. Extract metric_class = metric.__class__.__name__ (MeanMetric, RatioMetric, etc.)
2. Match paradigm:
- "frequentist":
If MeanMetric -> return "frequentist_welch_t_test"
If RatioMetric -> return "frequentist_ratio_delta_test"
- "bayesian":
If BinaryMetric -> return "bayesian_beta_binomial"
If MeanMetric -> return "bayesian_normal_normal"
- "sequential":
return "sequential_msprt"
- "bootstrap":
return "bootstrap_resampling"
3. Raise error if the combination is mathematically invalid.
| PARAMETER | DESCRIPTION |
|---|---|
metric
|
The target metric object (MeanMetric, RatioMetric, etc.) under analysis.
TYPE:
|
design_type
|
The desired statistical framework. Options:
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
Engine label string identifying the specific low-level calculation function.
TYPE:
|