Nodes/ComfyUI Iterative Mixing Nodes/Latent Batch Statistics Plot
ComfyUI Node Runs on cloud

Latent Batch Statistics Plot

Is your noised latent batch actually gaussian?

By ttulttul·Created 3 years ago·Updated about a year ago· 120
Latent Batch Statistics Plot
  • batch
  • plot_image

Every denoising sampler assumes the noise it's removing is (approximately) gaussian. Iterative mixing adds a twist: it keeps feeding the sampler noised versions of your own latent, and the whole scheme only holds together if those noised latents actually look like gaussian noise. This node is the pack's way of checking that assumption - it runs a proper statistical test on each latent in a batch and plots the results.

What it does

For every latent in your batch, it flattens the tensor, runs a Shapiro-Wilk normality test (scipy.stats.shapiro), and collects the p-value, mean, and standard deviation. Then it renders a single tall plot with three stacked panels:

  • Shapiro-Wilk p-values per batch element, with a red dashed line at 0.05 - the conventional "is this normal?" threshold. Points above the line: plausibly gaussian. Points below: suspiciously non-normal.
  • Mean of each latent - a random-ish wiggle around zero is what you want from noise.
  • Standard deviation of each latent - should track the sigma schedule as the batch progresses from clean to noisy.

Output: plot_image (IMAGE), a three-panel matplotlib figure you decode like any image.

Input: a single batch (LATENT). Feed it the latent_batch output of a Batch Unsampler and you'll see, at a glance, how the noising walk behaved at every step.

Why you'd reach for it

This is a debugging tool aimed at the pack's own core question: is the unsampler producing a clean, schedule-faithful sequence of noised latents, or has something gone sideways? Some genuinely useful spots:

  • After tweaking the unsampler - change scheduler, steps, or the deprecated normalize flag and see whether the p-values across the batch move. If the tail end of your batch stops being gaussian, that's a clue the noising schedule is off, which would explain weird downstream output.
  • As a teaching tool - it's a concrete, honest demonstration of what "add gaussian noise per the model's schedule" looks like when you measure it, rather than just trusting that it works.
  • It pairs naturally with Latent Batch Comparison Plot - one tells you what's in the batch, the other tells you whether it's normal.

Install

cd ComfyUI/custom_nodes
git clone https://github.com/ttulttul/ComfyUI-Iterative-Mixer
# restart ComfyUI

Or via ComfyUI Manager as "ComfyUI Iterative Mixing Nodes." No model downloads. The one dependency worth calling out: this node is the reason the pack's requirements.txt includes scipy - stats.shapiro is pure scipy. If you install the pack's requirements, it's there; if you're seeing ModuleNotFoundError: scipy it's because something skipped the requirements step, and pip install scipy fixes it instantly.

Real talk: this is a niche diagnostic from a niche pack, and it won't make your upscales prettier by itself. It exists because the author was trying to understand why the old KSampler-era output was grainy, and he kept the lab equipment around. For anyone who likes knowing why their pipeline behaves, it's a genuinely nice little tool.

Categorytests

Inputs (1)

NameTypeDefaultDescription
batchLATENT

Outputs (1)

NameTypeDescription
plot_imageIMAGE