FlexFit

What FlexFit does

FlexFit takes one or more datasets (every column of every file becomes a "dataset"), cleans the values — removing nulls, negatives, zeros and non-numeric entries — and fits a set of statistical distributions to each dataset, in the style of FlexSim's ExpertFit module. The result is, for each dataset, a ranking of distributions by goodness of fit (Score), ready to be used in simulation models.

The workflow has two screens: Execution, where you point to the files and start processing, and Results, where you check data quality and explore the fitted distributions.

Screen fields

The fields appear in this order on screen, from top to bottom.

Execution tab
Execution tab — input fields and file list.

1. Analysis Name

A free-form name for the analysis (e.g. Compressors, Pumps_Jan2026). It defines the name of the results folder, always in the format:

YYMMDD_{Name}_V01

YYMMDD = today's date · V01 = first version of this analysis.

2. File Upload / "Input files" list

Add one or more files (folder button or drag and drop). Accepted formats: Excel (.xlsx, .xls, .xlsm, .xlsb), CSV (.csv, .tsv, .txt), Parquet and databases (.db, .sqlite). Every numeric column of every file becomes an independent dataset in the final ranking.

Duplicate names You cannot add two files with exactly the same name to the same analysis — this prevents accidentally mixing two versions of the same source file.

3. Worksheet Name

Name of the Excel worksheet to read, per file — click a file in the list on the right to edit its worksheet individually. Leave it empty to always use the first sheet of the file.

4. Output Path and Same location as input

Manually pick the folder where the analysis will be saved, or turn on Same location as input to save each result automatically in the folder of its source file.

If the files come from different folders, each source folder becomes a separate analysis — Run processes one at a time.

5. Refit

Optional checkbox next to the Run button. See How Refit works — worth understanding before deciding whether to turn it on.

6. Include Min/Max

Optional checkbox next to Refit. When on, the exported Excel workbook gets two extra columns in the Results sheet — Min and Max, taken from the raw data of each dataset — ready to paste into FlexSim's distribution table as cutoff parameters. See The exported Excel workbook.

7. Run

Starts the data cleaning and the distribution fitting. A progress bar follows the steps; when it finishes, the app switches on its own to the Results tab with a summary of the files and datasets processed.

How Refit works

After the Initial Fit — the first round of distribution fitting, applied to the original sample — each dataset already has a ranking of distributions by Score. With Refit on, FlexFit takes the top 3 distributions from that ranking and runs a second test: it generates a synthetic sample from the already-fitted parameters of each one, then refits the distribution on that synthetic sample.

This works as a second opinion — if the distribution really does describe the data well, it should keep fitting well to synthetic data generated from itself. When the refit finds a better fit, it replaces the original entry in the ranking; when it does not, the Initial Fit result is kept.

When to turn it on Recommended for final simulation decisions, where confirming the top 3 is worth it. You can leave it off for a quick first exploration of the data — Refit adds processing time.

Summary panel

At the top, the Input file selector chooses which dataset you are looking at — if the analysis has more than one file or more than one valid column, each one appears here. Changing the dataset in this selector automatically updates the Fit panel beside it.

Results tab
Results tab — overview: Summary (left) and Fit (right) panels.
Summary panel
Summary panel — Data Quality and Statistics.
Block Field What it shows
Data Quality Total Data Total number of rows read from the column, before any cleaning.
Null Data Empty/null cells found.
Non-numeric Values that could not be converted to a number.
Zero Values Values equal to zero (removed from the fit).
Negative Values Negative values (removed from the fit).
Statistics Data Used How many values remained after cleaning — this is the sample that feeds the fit.
Minimum / Maximum Smallest and largest value of the cleaned sample.*
Mean / Median Mean and median of the cleaned sample.
Std Dev Standard deviation of the cleaned sample.

* Min and Max are rounded to 3 decimal places for display only.

Fit panel

Lists every distribution tested for the current dataset, sorted by Score (0 to 100 — the higher, the better the fit). Tick a row's checkbox to see its details; tick more than one to overlay the curves on the chart beside it and compare them visually.

Fit panel
Fit panel — distribution list, formula, parameters and chart.

The focused distribution appears in a format ready to use in FlexSim, and the icon beside it copies the whole string (name + parameters):

gamma(0.991412, 21.366221, 1.353314)

The badge next to the Score summarises the quality of the fit:

Badge What it means
⭐ Excellent Score ≥ 90 — excellent fit.
🟢 Good Score 70-89 — good fit, you can use it with confidence.
🟡 Acceptable Score 50-69 — acceptable, but worth checking the diagnostic charts before deciding.
🟠 Poor Score 30-49 — low score, the distribution did not fit the data well.
🔴 Very Poor Score below 30 — the distribution is not a viable option for this dataset.

Erro

Next to the Score, Erro shows the Kolmogorov-Smirnov statistic as a percentage — the largest gap between the real data's cumulative curve and the fitted curve's, at its single worst point. While the Score ranks this distribution against the others tested, Erro answers a different question: how far off is this specific curve from the data, on its own.

Because they answer different questions, Score and Erro do not always move together. Here is what each combination means in practice:

Score Erro What it means
Good (≥70) Good (low) Strong signal — the curve fits well both overall and at its worst point. The ideal case; use it with confidence.
Good (≥70) Poor (high) The fit is good "overall" (the other tests compensate), but there is one specific point — usually in the tail — where the curve drifts noticeably from the real data. Worth checking the diagnostic charts before deciding.
Poor (<50) Good (low) More common on very large samples (VERY_LARGE), where Score leans on AIC/BIC rather than the statistical tests — the distribution can have a small worst-point error yet still lose the overall comparison against the other candidates.
Poor (<50) Poor (high) Both signals agree: not a good distribution for this dataset.
When Erro shows "N/A" This is not a bug. It happens when the dataset has fewer data points than the distribution has parameters (e.g. a 4-parameter distribution fitted to only 3 samples) — there isn't enough data left to run the underlying statistical test. It is a sign the dataset is too small for that particular distribution, not a system error.

The 6 diagnostic charts

Below the table, choose the chart type to visually assess the ticked distribution(s).

Chart type selector
Chart type selector and the Show All Fits checkbox, below the chart in the Fit panel.
Chart What it shows Good sign
Histogram + KDE + PDF Bars (real data) + KDE (non-parametric smoothing) vs. the theoretical PDF of the fitted model. The PDF line runs through the centre of the bars and follows the KDE.
Frequency Comparison Observed relative frequency (bars) vs. the frequency expected by the model (line), per bin. The expected line follows the top of the bars.
Empirical vs Theoretical CDF Empirical CDF (Hazen method) vs. the theoretical CDF of the model, step by step. The curves overlap across the whole domain.
CDF Difference ECDF(x) − F(x): the CDF residual point by point; the shaded area shows the direction and size of the deviation. The curve oscillates near zero, with no persistent trend.
Q-Q Plot Theoretical quantiles (x axis) vs. empirical quantiles (y axis), with a 95% confidence band. Points sit on the diagonal and inside the confidence band.
P-P Plot Theoretical probability (x axis) vs. empirical probability (y axis), on the [0,1]×[0,1] square. Points sit on the diagonal across the whole probability range.

The exported Excel workbook

Every processed file gets an Excel workbook saved in the analysis folder, with a Results sheet — a single table stacking every dataset and every ranked distribution, ready to paste into FlexSim's own distribution table. This is the main deliverable of the analysis; the Fit panel on screen and the exported dashboard PNG both show the same data this sheet holds.

Column What it shows
Dataset Name of the dataset (file + column).
Rank Position of this distribution in the dataset's ranking — 1 is the best Score.
Regime Sample-size bracket used to weight the Score (SMALL, MEDIUM, LARGE, VERY_LARGE).
N_Samples Number of cleaned data points used for this dataset.
FlexScript Distribution The formula ready to paste into FlexSim — same string the copy icon in the Fit panel copies.
Python Distribution The same distribution, written in scipy/Python parameter order.
Min / Max (optional) Only present when Include Min/Max is checked. Minimum and maximum of the raw data for this dataset — not the fitted distribution's own cutoff parameters.
Erro Same value shown in the Fit panel — can read "N/A" (not a bug, see above).
Score Same 0-100 ranking value shown in the Fit panel.
Classification Same quality badge shown in the Fit panel (Excellent/Good/Acceptable/Poor/Very Poor).

Exporting the diagnostic dashboard

The Export button, below the distribution table, generates a single PNG image with the 6 charts side by side (2×3 grid), a header with the dataset name and a title on each panel — ready to paste into a report or send by e-mail, with no dependency on any file in the results folder.

Exported diagnostic dashboard
Example of an exported dashboard — the 6 charts in a 2×3 grid, with header and dataset name.
It goes stale if you change the selection The exported PNG reflects the distribution(s) ticked in the table at the moment you click — change the selection before exporting if you want to compare a different combination.