int_calculate_statistics(mki-整数计算统计)
21 stats over any number of integers
- *
ComfyUI's math nodes do arithmetic, but arithmetic isn't statistics. If you've got a pile of integers - a batch of seeds, strengths, step counts, whatever - and you want their mean, median, variance, or a z-score, int_calculate_statistics_makki (display name "int_calculate_statistics(mki-整数计算统计)") computes 21 different statistical measures over as many integer inputs as you care to wire in.
How it works
The node takes dynamic integer inputs - connect one int and another input slot appears, same pattern as the pack's dynamic-image nodes - and then, based on the stat_mode you pick, computes one measure over the whole set. The full menu:
- Basics:
count,sum,mean,min,max,range - Order stats:
median,quartiles,iqr,mode,sorted_list,unique_values,cumulative_sum - Spread:
variance,std_dev,mad(mean absolute deviation) - Shape:
skewness,kurtosis(excess kurtosis, so a normal distribution reads 0) - Relational:
frequency,proportions,z_scores
The single output is typed * because what comes out depends on the mode: count returns one integer, variance one float, quartiles a list of three, z_scores a list of one per input, frequency a dict. Wire it into whatever consumer matches the shape.
Where it earns its keep
Honestly? Debugging and scheduling. People use it to sanity-check a batch of generated seeds (mean/range tells you if your "random" values are actually covering the space), to summarize a set of metrics, or to feed a single representative value downstream - e.g., compute the mean of several measured values and hand that to a strength control. The median is handy when one outlier would wreck a mean. It's a utility node, not a workhorse, but when you need a quick summary it's the difference between five math nodes and one.
Gotchas
- Empty input is handled, but not gracefully everywhere. With no integers connected,
countreturns 0; every other mode returnsNone. So if you run it unconnected you getNoneflowing into whatever you wired it to. proportionsdivides by the sum - if your integers sum to zero you'll get a division blow-up. Keep inputs nonzero for that mode.modereturns a list, not a single value - multiple values tie for most frequent and you get all of them. Don't wire it somewhere expecting one number.z_scoreson a set with zero variance returns all zeros rather than crashing. That's a deliberate guard; it just means "everything is the mean," which is technically true.
Installing
It's part of ComfyUI-MakkiTools:
cd ComfyUI/custom_nodes
git clone https://github.com/MakkiShizu/ComfyUI-MakkiTools
cd ComfyUI-MakkiTools
pip install -r requirements.txt
Restart ComfyUI. Pure Python math + collections.Counter under the hood, no dependencies. It won't replace a spreadsheet, and the output typing ("what comes out depends on the mode") can trip up strict workflows - but for a quick summary of a batch of integers inside the graph, it's genuinely convenient.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| stat_mode | COMBO | count | Statistical measure to calculate 要计算的统计量 |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| * | * | — |