An interactive statistical inference and visual analysis system built with React and ECharts. This project is designed to map core theorems in mathematical statistics—such as the Neyman-Pearson Lemma and the Karlin-Rubin Theorem—into dynamic visual feedback, transforming the internal mathematical logic of optimal hypothesis testing into quantifiable, interactive parameterized models.
The theoretical framework of classical statistical inference relies on highly abstract mathematical concepts: Sufficiency, Completeness, Likelihood Ratios, Monotone Likelihood Ratio (MLR) families, Uniformly Most Powerful (UMP) tests, and Power Functions. In conventional analytical derivations, the geometric mapping and decision-theoretic intuition of these concepts are often difficult to observe directly.
This project builds a bridge between abstract theoretical equations and dynamic data visualization. Through direct manipulation of parameter spaces and immediate system feedback, it aims to achieve the following core objectives:
- Visualize the impact of sampling variability on statistical inference boundaries.
- Verify and visualize the information-lossless nature of Complete Sufficient Statistics via graphical mapping.
- Quantify the trade-off between the Size (Type I error rate) and Power of hypothesis tests in a dynamic, interactive environment.
- Construct and solve the parameter space mapping of global power curves.
- Reveal the complementary nature of the
$p$ -value as a continuous evidence scale within both the Fisherian framework and Neyman-Pearson decision theory. - Verify the extremum properties of the Neyman-Pearson Lemma in "simple vs. simple" scenarios, and extend this to one-sided UMP tests in MLR families via the Karlin-Rubin Theorem.
The architecture of this system follows a rigorous statistical analysis logic, providing a continuous experimental workflow:
- Empirical Data Generation & Prior Blind Testing: The system instantiates a random distribution family in the background and generates a sample set (including Kernel Density Estimation) using Monte Carlo methods, completely hiding the Data Generating Process (DGP). Users must formulate prior model assumptions based solely on empirical distribution shapes, thereby validating the potential impact of Model Misspecification on subsequent inference.
-
Formal Hypothesis Formulation: Under a specified probability model, users strictly define the parameter subspaces for
$H_0$ and$H_1$ . The system performs automated validation of nesting and MLR conditions, outputting standard mathematical logic notation. -
Dimensionality Reduction & Sufficiency Verification: Demonstrates how the high-dimensional multivariate sample space
$\mathbb{R}^n$ projects onto a one-dimensional complete sufficient statistic$T(X)$ (e.g., sample sum), visually interpreting the dimensionality reduction effect of the Fisher-Neyman Factorization Theorem. - Optimal Test Boundary Analysis: Renders the power functions of an "arbitrary rejection region" alongside a "likelihood-ratio rejection region". By adjusting threshold parameters, the system dynamically integrates Size and Power, proving optimality under the Neyman-Pearson framework.
-
Evidence Scale Quantification (
$p$ -value): Locates the observed statistic within the sampling distribution space of$T$ , integrates the tail extremes, and calculates a high-precision theoretical$p$ -value. -
Post-Hoc Analysis: The system finally decrypts the underlying true DGP. Based on the designated
$\alpha$ threshold, it evaluates the validity of the test decision, rigorously determining the occurrence of Type I (False Positive) or Type II (False Negative) Errors.
The underlying algorithmic engine supports a range of non-negative probability distributions that possess complete sufficient statistics and strictly satisfy the Monotone Likelihood Ratio (MLR) property. For the selected families, the complete sufficient statistic is uniformly the sample sum
-
Poisson (Unknown mean):
$\mathrm{Pois}(\lambda)$ , where$\lambda>0$ . -
Binomial (Known trials, unknown probability):
$\mathrm{Bin}(n,p)$ , where$n$ is fixed,$p\in(0,1)$ . -
Exponential (Unknown rate):
$\mathrm{Exp}(\lambda)$ , where$\lambda>0$ . -
Geometric (Unknown probability, support
$1,2,\dots$ ):$\mathrm{Geom}(p)$ , where$p\in(0,1)$ . -
Gamma (Known shape, unknown scale):
$\mathrm{Gamma}(k,\theta)$ , where$k$ is fixed,$\theta>0$ .
These models encompass typical discrete and continuous probability measures. For discrete distributions, the engine supports theoretical extensions for Randomized Tests to ensure exact control over a given significance level
Utilizes Gaussian Kernels to calculate a continuous density approximation for sample data. Theoretical model parameters are hidden, exposing only descriptive statistics and KDE curves.
Provides rigorous boolean logic boundary configurations (closed intervals, open intervals, point hypotheses), dynamically blocking invalid or overlapping hypothesis formulations.
Employs high-precision numerical methods (e.g., Beasley-Springer-Moro rational approximation) to plot the continuous trajectory of
High-contrast delineation of acceptance and rejection regions. Real-time rendering of Type I and Type II error distribution areas via numerical integration.
To ensure academic-grade precision and offline availability, this system does not rely on any external black-box statistical APIs (e.g., R, SciPy). All theoretical distributions and critical value calculations are implemented from scratch in a custom, pure JavaScript computational engine (src/utils/math.js):
- Gaussian Kernel Density Estimation (KDE) algorithms.
- Efficient Abramowitz-Stegun approximation expansion for Standard Normal CDFs.
- Beasley-Springer-Moro rational approximation for Inverse Normal CDFs (Probit function).
- Wilson-Hilferty transformations and quantile inversion calculations for Gamma and Exponential families.
- Critical boundary bounding algorithms with continuity corrections for discrete distributions.
- Frontend Framework: React 18 (Component-based architecture with closed-loop state management).
- Build Tool: Vite (Hot Module Replacement and production-grade obfuscation/bundling).
- Visualization Layer: Apache ECharts (High-performance Canvas rendering and data-driven graphics).
- Core Algorithm: Vanilla JS (Custom-built mathematical statistics underlying function library).
- Introduce two-sided UMPU (Uniformly Most Powerful Unbiased) test algorithms in the underlying engine.
- Implement conditional inference mechanisms for non-MLR scenarios (e.g., multimodal distributions or mixture models).
- Expand the parameterized model space to a broader range of exponential families (Inverse Gaussian, Negative Binomial).
- Construct an automated analytical report export module (complying with LaTeX typesetting standards).
Statistical Inference Visual Lab — Translating abstract derivations into visible parameter matrices.