ComfyUI Node

Ptd Normal

Ptd Normal — the bell curve as a node, ready to sample and score

By HowToSD·Created about a year ago·Updated about a year ago· 7
Ptd Normal
    • PTDISTRIBUTION
    loc
    scale

    If you're going to reach for any distribution in this pack, it's this one. PtdNormal builds a normal (Gaussian) distribution - mean and standard deviation in, a PTDISTRIBUTION object out - and it's the natural starting point for the pack's whole Ptd*/Ptdm* family. You can't sample a curve, score a point, or invert a probability until some node has defined the distribution, and this is the one most people will wire first.

    It ships inside ComfyUI-Pt-Wrapper, HowToSD's no-code PyTorch toolkit. The pack has ~200 nodes for tensor math, model building, and training, but the distribution subset is its quiet little statistics lab. Perfect for adding noise with a controlled shape, generating synthetic data to feed a training pipeline, or just plotting a bell curve in the graph.

    How it works

    Mechanically it's a thin wrapper around torch.distributions.Normal. The node parses your loc and scale text with literal_eval, builds torch.tensor values, and returns a native torch Normal - no subclass, no scipy shim, because PyTorch implements everything the query nodes need for a normal out of the box, including both cdf and icdf. That means PtdmIcdf on a normal works without any hidden helper.

    Inputs that matter

    • loc - the mean. Type a Python literal: 0.0 for a plain single normal, or a tuple like (0.0, 5.0, -2.0) for a batch of three means.
    • scale - the standard deviation. Must be positive. 1.0, or a tuple matching loc.

    Both are STRING inputs, so you type text, not numbers. 1.0 works, 1 also works, but a stray space or letter makes literal_eval throw and the node turns red before it ever runs.

    Output is a single PTDISTRIBUTION socket. Wire it into PtdmSample to draw random values, PtdmPdf to score how likely a value is, PtdmCdf for the cumulative probability, or PtdmIcdf to go from a probability back to a value (handy for computing quantiles or z-scores visually).

    Installing it

    Same story as every node in the pack - ComfyUI Manager, search "Pt Wrapper", install, restart. Or the manual route:

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

    Then restart ComfyUI. The pack's first install is slow because requirements include matplotlib, pandas, scipy, scikit-learn, transformers, datasets and a pinned gensim==4.3.2. No model files download for the distribution nodes - this is pure math.

    Common issues

    The only real traps are the text inputs (see above) and parameter confusion: scale is standard deviation, not variance. A common beginner move is entering 2 thinking it's variance; for a variance of 4 you need scale 2.0. And remember the scale must be positive - a zero or negative value makes the distribution invalid. When in doubt, start with loc=0.0, scale=1.0, sample a thousand values, and check the mean and spread with the pack's stats nodes.

    CategoryDistribution

    Inputs (2)

    NameTypeDefaultDescription
    locSTRING
    scaleSTRING

    Outputs (1)

    NameTypeDescription
    PTDISTRIBUTIONPTDISTRIBUTION