ComfyUI Node

Ptd Uniform

Ptd Uniform — the simplest distribution in the pack, and a handy noise source

By HowToSD·Created about a year ago·Updated about a year ago· 7
Ptd Uniform
    • PTDISTRIBUTION
    low
    high

    The uniform distribution is the "everything between a and b is equally likely" distribution, and PtdUniform is the easiest node in the Ptd* family to wrap your head around. Two numbers in, a PTDISTRIBUTION out, and suddenly you have a legitimate way to inject controlled random noise, jitter data, or generate synthetic training samples inside ComfyUI - no code, no extra libraries, no model downloads.

    It's part of ComfyUI-Pt-Wrapper, HowToSD's no-code PyTorch environment. In the wider pack this node slots into the data-science workflows: add uniform noise to a tensor before training a classifier, build a simple data augmentation step, or sample random starting points for whatever you're plotting. It's not a diffusion node - if you're here for image gen, you can skip it and nothing breaks.

    How it works

    Thin wrapper over torch.distributions.Uniform. The node parses your low and high strings with literal_eval, converts them to float tensors, and returns the native torch distribution. Because torch's Uniform implements both cdf and icdf natively, there's no scipy shim hiding here - every Ptdm* query node works with it out of the box. That makes it the safest distribution to learn the family on.

    Inputs that matter

    • low - minimum value, inclusive.
    • high - maximum, exclusive.

    Both are STRING fields parsed as Python literals. 0.0 and 1.0 give you the classic unit uniform. Tuples work too - (0.0, 10.0) and (5.0, 15.0) builds two distributions you can sample as a batch. Watch it: high must be strictly greater than low, or torch rejects the distribution.

    The single output is PTDISTRIBUTION. Feed it to PtdmSample for random draws, PtdmPdf (which just returns 1/(high-low) inside the range), PtdmCdf, or PtdmIcdf to convert a probability back to a value.

    Installing it

    ComfyUI Manager: Install Custom Nodes → search "Pt Wrapper" → install → restart. Or manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/HowToSD/ComfyUI-Pt-Wrapper
    

    Restart ComfyUI after. The pack's dependency list is the heavy part - matplotlib, pandas, scipy, scikit-learn, transformers, datasets, pinned gensim==4.3.2 - so the first install takes a while even though this specific node needs almost nothing.

    Common issues

    The recurring theme: these are text inputs. An empty low or a typo kills the run with a SyntaxError from literal_eval. And mind the semantics - high is exclusive, so if you sample a uniform (0.0, 1.0) you'll never quite see 1.0. That rarely matters, but if you're using it for seeded data you might wonder why the max is always just under the bound. It's not a bug, it's the definition.

    CategoryDistribution

    Inputs (2)

    NameTypeDefaultDescription
    lowSTRING
    highSTRING

    Outputs (1)

    NameTypeDescription
    PTDISTRIBUTIONPTDISTRIBUTION