Nodes/comfyui-lopi999-nodes/Random Normal Distribution
ComfyUI Node

Random Normal Distribution

Random numbers that cluster around a value, not every value equally

By LaVie024·Created about a year ago·Updated 8 months ago· 8
Random Normal Distribution
    • float
    • integer
    • show_help
    mean0.00
    std_dev1.00
    enable_min_maxfalse
    seed0
    minimum0.00
    maximum1.00

    Every random number generator in ComfyUI's stock arsenal is uniform: every value in the range is equally likely, which means "random strength between 1 and 5" spends half its time giving you extremes. RandomNormalDistribution does something different. It samples from a bell curve around a mean, so most draws land near your target value and the extremes are rare. The author built it specifically because uniform randomness was annoying him for batch work - "why not normal distributions as well?" - and it's a genuinely different tool for the right job.

    Why you'd reach for it

    This is a "controlled randomness" node. If you want a batch of 50 generations where the CFG hovers around 7 with the occasional 6.4 or 8.1, a normal distribution gives you that; uniform randomness would give you flat 4.0s and 10.0s as often as the 7.0s. The classic use is nudging a parameter slightly around a base value for large batches - variation without chaos. It's also great for strength-cycling in img2img where you want most results near a target denoise and only occasional excursions.

    How it works

    The implementation uses a proper normal sampler seeded from the seed input, drawing from N(mean, std_dev). The std_dev (standard deviation) is the knob that matters: with a mean of 0 and std of 1, roughly 68% of draws land between -1 and 1, and 95% between -2 and 2. You can optionally enable enable_min_max to clamp the result into a minimum/maximum range - useful for keeping a value inside a slider's valid bounds, like denoise between 0.4 and 0.8. If minimum ends up above maximum the node silently swaps them, which is a nice touch of defensive coding.

    One thing to know: the int output is the float rounded to the nearest whole number (int(round(value))), so 2.6 becomes 3. If you need truncation instead, you'll want to handle it elsewhere.

    The inputs that matter

    • mean (FLOAT, default 0) - the center of the bell curve. Your "base" value.
    • std_dev (FLOAT, default 1) - how spread out the draws are. Smaller = tighter around the mean.
    • enable_min_max (BOOLEAN) - turns on clamping.
    • seed (INT) - reproducibility. Same seed, same sequence.
    • minimum / maximum (FLOAT, optional) - the clamp range, only used when enable_min_max is on.
    • float / integer - the draw as a float and as a rounded int.
    • show_help (STRING) - a readout of the mean, std dev, min/max state, and the values drawn. Handy mid-debug.

    Installing it

    Part of comfyui-lopi999-nodes:

    cd ComfyUI/custom_nodes
    git clone https://github.com/LaVie024/comfyui-lopi999-nodes
    

    Restart ComfyUI, or grab it from ComfyUI Manager by searching "comfyui-lopi999-nodes." No models, no extra dependencies.

    Common issues

    The most common mistake is setting a small std_dev and expecting range. With mean 7 and std 1, you will essentially never see a 5 or a 9 - that's the point, but it surprises people the first time. And don't rely on the clamp to make the distribution uniform; it just cuts off the tails, so values pile up at the clamp edges. If you wanted flat randomness, you want the uniform generators, not this node.

    Categorylopi999/random

    Inputs (6)

    NameTypeDefaultDescription
    meanFLOAT0.00-1000000000–1000000000
    std_devFLOAT1.000–1000000000
    enable_min_maxBOOLEANfalse
    seedINT00–18446744073709550000
    minimumoptFLOAT0.00-1000000000–1000000000
    maximumoptFLOAT1.00-1000000000–1000000000

    Outputs (3)

    NameTypeDescription
    floatFLOAT
    integerINT
    show_helpSTRING