Introduction¶
DSH’s philosophy is “Everything is a Plugin”. Data analysis tasks can be implemented as panels, rather than simply pasting results back and forth in chat. A common research path involves pasting data from Excel into Python, running candidate distributions through scipy.stats, and then manually drawing histograms, adjusting fonts, tweaking colors, and generating plots according to journal column widths. Fitting, testing, ranking, and plotting are four separate tasks; however, since every new dataset requires repeating the entire process, the time spent on plotting often exceeds the time spent on calculation.
DistFit consolidates this pipeline into an independent panel on the left sidebar of the GUI. The maintainer is stormx-u. The repository name is dsh-easydistfit (project name on GitHub is dsh-easydistfit, name in package.json is dsh-distfit), it uses the MIT license, and falls under the category of Model Inference Tools. It chains together 23 distribution families, four types of goodness-of-fit tests (K-S/A-D/CvM/χ²), AIC ranking, AI interpretation, and paper/PPT template plotting into a workflow. The statistical part is implemented in pure JavaScript and does not depend on Python or SciPy. Upon installation, in addition to the panel, the distfit_fit tool is registered, allowing the assistant in the chat to call it directly.
Installation and Enablement¶
First, install from this repository, replacing <本仓库路径> with the cloned directory:
dsh plugin --profile web add link:"<本仓库路径>"
You can also install local directories or repository directories via the “Plugins” page in the GUI. After installation, the “Distribution Fitting” icon appears in the left sidebar; click to use. Client-side changes require a page refresh, while Host-side changes (Tools, AI routing) require a restart of DSH.
The runtime requirements are documented in two places: >= 0.1.7-rc.1 in the README for DSH, and >=0.1.0 for dsh.engines.dsh in package.json. Building and testing require Node.js 24+. The current version in package.json is 0.6.0.
Data and Fitting¶
Two input types are supported: pasting CSV/TSV (first row as column names) or directly pasting multi-column data copied from Excel. Each column is fitted independently. Null values and non-numeric values are automatically removed, and outliers are removed according to the IQR rule, with the number of removed items displayed on the interface.
It includes 23 built-in distribution families: Normal, Logistic, Laplace, Cauchy, Uniform, Log-Normal, Gamma, Weibull, Exponential, Rayleigh, Inverse Gaussian, Log-Logistic, Lomax (Pareto II), Burr XII, Fatigue Life (BS), Nakagami, Maxwell, χ², Half-Normal, Beta, Gumbel, GEV, and GPD. They are displayed in groups such as “Location-Scale / Right-skewed Lifetime / Extreme / Bounded & Others”. You can check specific ones, select all at once, or use only the six “Common” families.
Parameter estimation uses Maximum Likelihood Estimation (MLE). It first uses Moments Estimation for initial values, followed by grid refinement and numerical minimization. The estimation results are written directly into the table. Parameters are presented in a Chinese format such as μ 位置=…, σ 尺度=…, with confidence intervals/quantiles listed side-by-side with empirical quantiles for easy reliability assessment.
Testing and Ranking¶
The testing section provides four types: K-S, A-D, CvM, and χ². The default output is asymptotic p-values, but you can switch to “Monte Carlo Calibration” mode (parameter bootstrap with B=999) for higher accuracy, though it is slower. P-values in the table can be checked per column to avoid clutter when there are too many columns.
Ranking uses AIC / BIC / ΔAIC / Akaike weights. You can sort by AIC, BIC, or K-S p-value. The conclusion column directly provides three levels: “Accept”, “Partial Reject”, or “Reject”, reducing the workload of setting thresholds yourself.
Charts¶
The charts have four tabs: Histogram with PDF curves, CDF comparison, P-P, and Q-Q. All are drawn using vector SVG. Hovering displays the frequency, density, and distribution density values for that bin. The legend can be clicked to highlight a specific curve; when there are many curves, they automatically collapse into “+N curves”. Dragging thresholds or switching curves is done locally in the browser, and feedback is instant because the statistical engine is pure JS.
AI Interpretation¶
After calculating results, the panel sends the statistical summary to DSH’s model channel, generating a four-part interpretation that is directly displayed below the KPI cards:
- What the data reveals: center and dispersion, skew direction, tails and extremes, value range, whether the histogram is unimodal or has gaps, and what these features imply for the underlying process (which column is more stable, where anomalies might exist, high or low risks). Each judgment is linked to specific numbers in the summary.
- Recommended distribution and rationale.
- Risks and considerations.
- Next steps.
The panel does not store any keys. POST /api/dsh-distfit/explain routes to the Host, where DSH’s llm service performs a short completion based on the “assistant’s current default model”: it prioritizes agentDefaultModel and automatically selects an available provider/model if unavailable. Therefore, as long as the model channel in the current profile is available, AI interpretation works; switching models or providers follows DSH settings without needing plugin changes. The model call occurs on the Host side, so the browser does not have access to credentials. You can manually click “Re-analyze”, and the interpretation will also be included in the exported Markdown report.
Small Sample Hints¶
When the sample size \(n < 15\), a warning appears at the top of the panel. Distribution families with 3-4 parameters (such as Beta, Burr, GPD) are marked with ⚠ in the ranking. This is to prevent conclusions from small-sample overfitting from being treated as definitive.
Chart Export¶
Click “Export Chart” in the top-right corner of the chart card to enter the export dialog. The left side is a WYSIWYG preview, and the right side has three tabs: Template / Style / AI Adjust.
Available canvas sizes include 1280×720 (16:9 slides), 1600×900, 1200×800, 2400×1350, 900×600, and custom. For styling, you can adjust font size (0.5×–5×), line width (0.3×–6×), legend font size, bitmap ratio (1×/2×/3×), switch to grayscale (converted via BT.601 luminance, suitable for black and white printing), toggle grid lines, bar strokes, transparent backgrounds, axis styles (L-shape or full frame), legend position (bottom / right / hide), and chart title. For bar charts, you can separately adjust fill depth (Light / Medium / Deep / Hollow), bar spacing (0–40 px), bar radius (0–40 px), and bar color; the default style is “Light + Thin Stroke + 2 px Gap + 3 px Radius”.
It includes seven built-in plotting templates; clicking one instantly swaps fonts, sizes, line widths, axes, and legends:
- Default (Color · Grid)
- Chinese Journal · Double Column
- English Journal · Single Column
- Thesis
- Presentation · 16:9
- Presentation · Transparent Background
- Black and White Print
The line widths in the templates scale proportionally with the canvas width (e.g., ~3× font size at 1800 px), remaining clear even when scaled down to journal column widths. The current style can be saved as your own template to localStorage, deleted, and reused next time.
Export formats support SVG (vector, text remains selectable text), PNG, JPG, and PDF. Filenames are of the form distfit-wood-density-20261105-151543.pdf. In dark mode, exported images automatically convert light text and reference lines to dark colors suitable for a white background.
Preview equals export: The dialog first renders the current chart off-screen into a hidden container .df-export-stage (with dimensions equal to the export pixels), then uses buildExportSvg to serialize the same SVG to generate the preview. When exporting, the same string is reused, avoiding the issue of “preview looks good, but export looks small”.
AI Chart Adjustment¶
In the “AI Adjust” tab, describe the purpose in one sentence, for example, “target a Chinese core journal, double column, grayscale and printable, larger font size” or “group meeting PPT, dark background, big text”. The model on the Host side translates this into a style patch (which can specify a preset plus override fields), applies it to the preview, and provides a Chinese explanation. The model can only modify style fields; data and statistical results will not be altered.
This route uses POST /api/dsh-distfit/chart-style, sending {request, context} and returning {ok, preset, style, notes, warnings}. The Host uses a field whitelist and ranges to trim the model output into a valid patch; the model cannot inject arbitrary CSS/HTML. The model also comes from DSH’s llm service and the assistant’s default model, and the call occurs on the Host side.
Typical Usage¶
A complete workflow from the panel can be as follows:
- Copy multi-column data from Excel and paste it into the panel’s input area, confirming that the column names are correct.
- First, run with the six “Common” families to check the AIC ranking and the K-S p-value checkmarks; if the results are satisfactory, check all 23 families for comparison.
- Open the “Histogram + PDF” tab, click on the top two distributions in the legend to see the curve fit.
- Adjust chart style: select a thesis template, fine-tune font size and bar color, and use one sentence to describe the purpose in “AI Adjust”.
- Export PDF or SVG for the paper, export the ranking table to CSV, or generate a Markdown report containing AI interpretation in one click.
When you need to interrupt and resume analysis in a chat, you can call the registered distfit_fit tool to let the assistant directly fit the data and provide ranking suggestions; the Host side reuses the same statistical engine.
Project Structure and Self-Check¶
The division of statistics and interface code is as follows: src/engine/ is the pure JS engine (special functions, distribution families, descriptive statistics, tests, orchestration), shared by the browser and Host; src/host/ carries the distfit_fit tool, AI interpretation, and chart style routing; src/client/ is the panel interface and export logic. The client build uses esbuild:
node build.mjs # Generates lib/client.js; must rebuild after changing client code
npm test # Eight self-checks: engine, end-to-end stats, Host tool, AI summary, chart export, legend, style, client package smoke
npm run test:chart # Runs chart export only (grayscale conversion, filename, PDF structure)
Applicable Scenarios and Notes¶
Suitable for research scenarios where one needs to find a distribution for a set of data and generate publishable charts, especially in environments where you don’t want to constantly switch between Python scripts and plotting tools. If it is a pure modeling task, use the distfit_fit tool; if you need to repeatedly tweak charts, the panel’s templates and style controls are more suitable.
A few notes: The plugin runs with the permissions of the current DSH process; you should check the source code and license before installing (this project is MIT, with README and docs/DESIGN.md provided in the repo for review). The browser side does not handle credentials, and the availability of AI interpretation depends on the current profile’s model channel. The plugin’s category in the community directory is Model Inference, with 1 star, indicating it is a new project; if you encounter issues, please submit an issue on GitHub directly. Remember to restart DSH after upgrading the plugin version, as Host-side code is loaded at process startup; otherwise, the AI cards will not function.
Conclusion¶
The value of DistFit lies in it putting the common research pipeline of “fitting—testing—ranking—interpreting—plotting” into a DSH panel, and its statistical implementation is entirely pure JavaScript without introducing Python dependencies, making it friendly to environments that only run DSH.
- Directory page: https://www.skillhub.cn/plugins/stormx-u/dsh-easydistfit
- GitHub: https://github.com/stormx-u/dsh-easydistfit