ComfyUI Node Runs on cloud

Random

A seeded random float between two bounds

By Derfuu·Created 3 years ago·Updated 2 years ago· 455
Random
    • FLOAT
    Value_A0.00
    Value_B1.00
    seed0

    Sometimes you want a value that jitters - a denoise that varies a little each run, a strength that wanders, a size that isn't nailed to one number. Random gives you a random float between two bounds you set, driven by a seed so it's reproducible. That last part is the whole point: it's not "chaos," it's "the same random number every time for a given seed," which is exactly what you want when you're building a workflow you can debug.

    How it works

    You set a low bound and a high bound, and the node returns a float somewhere in that range. The seed decides which float - same seed, same result; change the seed, get a different one. Because ComfyUI can auto-increment a seed each run, you can wire this so every generation gets a fresh-but-reproducible value, the same way your KSampler seed works.

    The inputs and outputs that matter

    • Value_A (FLOAT, default 0) - the low end of the range.
    • Value_B (FLOAT, default 1) - the high end. The default 0-to-1 range is handy for anything that takes a 0-1 weight.
    • seed (INT, 0 to 4294967295) - the reproducibility knob. Set it to a fixed number to freeze the value, or let ComfyUI randomize/increment it for variety across runs.
    • Output: FLOAT - the chosen value, wired into whatever you're jittering.

    Where it fits

    The obvious use is variety without losing control. Feed a Random into a denoise strength, a LoRA weight, or a Derfuu ratio-scaler and each run explores a bit of the space, but you can always reproduce a good one by locking the seed you liked. Pair it with Ceil or Floor if you need a random integer - say, picking a random size from a range - since the raw output is a float.

    How to install it

    ComfyUI Manager: search Derfuu_ComfyUI_ModdedNodes, install, restart. Manual install:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Derfuu/Derfuu_ComfyUI_ModdedNodes
    

    then restart. No dependencies, no models - plain Python.

    Common issues & troubleshooting

    The value never changes. A fixed seed produces a fixed result - that's by design. If you want it to vary run-to-run, set the seed control to randomize (or increment) rather than fixed, exactly like you would for a sampler.

    It changes every single run and you didn't want that. Opposite problem, same knob: lock the seed to a specific number to pin the value.

    You need a whole number. Output is FLOAT. Run it through Floor, Ceil, or Integer to get an INT for things like pixel dimensions.

    The range is backwards. If Value_A is larger than Value_B the range is inverted; keep low in A and high in B to avoid surprises.

    Missing node in a downloaded workflow. Derfuu has a track record of deleting deprecated nodes on pack updates instead of leaving them in place, so old graphs sometimes point at names that are gone - reconnect a current copy. A ModuleNotFoundError about Derfuu_ComfyUI_ModdedNodes_legacy means you have a duplicate folder; keep one named Derfuu_ComfyUI_ModdedNodes.

    CategoryDerfuu_Nodes/Functions

    Inputs (3)

    NameTypeDefaultDescription
    Value_AFLOAT0.00
    Value_BFLOAT1.00
    seedINT00–4294967295

    Outputs (1)

    NameTypeDescription
    FLOATFLOAT