ComfyUI Node

Ptd Student T

Ptd Student T — the fat-tailed distribution the pack had to rescue with scipy

By HowToSD·Created about a year ago·Updated about a year ago· 7
Ptd Student T
    • PTDISTRIBUTION
    df
    loc
    scale

    The Student's t-distribution is the normal's tougher cousin - same bell shape, but with heavier tails, which makes it the right tool whenever real-world data throws more outliers than a Gaussian can stomach. PtdStudentT builds one in ComfyUI: degrees of freedom, mean, and scale in, a PTDISTRIBUTION out. It's the distribution to reach for when your data has fatter tails than you'd like to pretend otherwise about.

    It lives in ComfyUI-Pt-Wrapper, HowToSD's no-code PyTorch lab. It's the middle sibling of the Ptd* family: three parameters instead of one or two, and the most patched-up under the hood.

    How it works

    The node constructs a torch.distributions.StudentT and wraps it in a StudentTEx subclass. This one earns its keep: PyTorch's StudentT implements neither cdf nor icdf - both throw NotImplementedError if you call them. The pack fills both in with scipy, using the standard trick of normalizing (x - loc) / scale and calling scipy.stats.t.cdf / t.ppf. That's a big part of why scipy is pinned in the requirements - take it away and this node's query half silently stops working.

    Like Poisson, Student's t is handled carefully by the query nodes: PtdmCdf and friends cast your input to a float tensor before evaluating, since there's nothing discrete about it.

    Inputs that matter

    Three text inputs, all parsed as Python literals:

    • df - degrees of freedom. Must be positive. Small values (like 1.0 to 5.0) give the fat tails; above ~30 it starts looking a lot like a normal.
    • loc - the center/mean parameter.
    • scale - spread, analogous to standard deviation. Positive.

    So df=5.0, loc=0.0, scale=1.0 is the classic setup. Tuples work for batching, as long as all three align. Output is a single PTDISTRIBUTION socket that feeds every Ptdm* query node.

    Installing it

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

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

    Restart ComfyUI after cloning. The dependency list is the usual heavy stack for this pack (matplotlib, pandas, scipy, scikit-learn, transformers, datasets, pinned gensim==4.3.2) - first install takes minutes, no model downloads involved.

    Common issues

    The text-input gotcha applies here more than anywhere: df, loc, and scale are strings, so an empty df or a typo throws a SyntaxError before the node even runs. Keep df and scale strictly positive - negative degrees of freedom is undefined and torch will reject it. And one expectation to set: because of the heavy tails, samples from a t with low df will occasionally look wild, with values nowhere near loc. That's the distribution doing its job, not a broken node.

    CategoryDistribution

    Inputs (3)

    NameTypeDefaultDescription
    dfSTRING
    locSTRING
    scaleSTRING

    Outputs (1)

    NameTypeDescription
    PTDISTRIBUTIONPTDISTRIBUTION