ComfyUI Node

Ptd Beta

A flexible distribution for probabilities and priors

By HowToSD·Created about a year ago·Updated about a year ago· 7
Ptd Beta
    • PTDISTRIBUTION
    alpha
    beta

    The Beta distribution is what you reach for when you want to model "a probability that isn't fixed" - it lives on [0,1], so it's the classic choice for uncertain success rates, Bayesian priors, and smoothing proportions. Ptd Beta turns two shape parameters into a real PyTorch Distribution object you can sample and score in the graph. In the pack's no-code training world, it's also the natural generator for noise or weights that stay bounded.

    How it works

    You give it alpha and beta, the two positive shape parameters, and it constructs torch.distributions.Beta with concentration1 = alpha and concentration0 = beta. Both fields are strings parsed with ast.literal_eval, so you can type a scalar (2.0) for a single distribution or a tuple ((2.0, 3.0)) for a batched one. The output PTDISTRIBUTION is the object, not a sample.

    The shape of the Beta is controlled entirely by those two numbers: alpha = beta = 1 gives a uniform on [0,1]; alpha and beta both large and equal gives a tight bell near 0.5; alpha > beta skews toward 1. For a beginner the intuition to hold onto: alpha is "mass for success", beta is "mass for failure", and the ratio decides where the probability concentrates.

    Like several other distribution nodes in this pack, it's actually a subclass that bolts on cdf and icdf methods via scipy - stock PyTorch Beta doesn't ship those. That's why scipy is a hard requirement for this pack. From there, wire the PTDISTRIBUTION into Ptdm Sample to draw values, Ptdm LogProb to score them, or Ptdm Cdf / Icdf for quantile work.

    The inputs that matter

    • alpha - first shape parameter; scalar or tuple literal.
    • beta - second shape parameter; scalar or tuple literal.

    Both are required. Leave one blank and ast.literal_eval("") throws a parse error - the empty defaults are the most common mistake on first use.

    Where people get burned

    • Non-positive parameters: alpha or beta at 0 or negative makes the distribution undefined; PyTorch will complain at construction or silently misbehave. Keep them positive.
    • Literal syntax: 2, 3 without brackets fails to parse; type 2.0 or (2.0, 3.0).
    • Forgetting this gives you a distribution, not a sample - you still need Ptdm Sample to get numbers out.

    Installing it

    Part of ComfyUI-Pt-Wrapper:

    • ComfyUI Manager → search "ComfyUI-Pt-Wrapper" → Install → restart.
    • Or cd ComfyUI/custom_nodes && git clone https://github.com/HowToSD/ComfyUI-Pt-Wrapper and restart.

    Heavy install - the requirements bring transformers, datasets, peft, accelerate, scikit-learn, scipy, gensim and sentencepiece. scipy matters specifically for the cdf/icdf extensions. No model downloads needed. It's a niche educational pack by HowToSD with minimal community presence; the repo's docs/reference/ is authoritative.

    CategoryDistribution

    Inputs (2)

    NameTypeDefaultDescription
    alphaSTRING
    betaSTRING

    Outputs (1)

    NameTypeDescription
    PTDISTRIBUTIONPTDISTRIBUTION