ComfyUI Node

Ptdm Cdf

Ptdm Cdf — ask a distribution 'how likely is anything up to here?'

By HowToSD·Created about a year ago·Updated about a year ago· 7
Ptdm Cdf
  • distribution
  • TENSOR
x

The cumulative distribution function answers the single most useful question in statistics: what's the probability a random draw lands at or below this value? PtdmCdf is the node that asks it. You feed it a PTDISTRIBUTION (from any Ptd* constructor) and a value, and it returns the CDF as a tensor. It's the "P(≤ x)" node.

It's part of ComfyUI-Pt-Wrapper, HowToSD's no-code PyTorch environment. The whole Ptdm* family reads from a distribution you built with a Ptd* node - nothing to install beyond the pack, and these query nodes are where the distribution stuff actually pays off: hypothesis checks, p-values, quantile work, and sanity-checking your own data against a model.

How it works

The node calls distribution.cdf() on your value. Behind the scenes it's smart about types: it parses your x with literal_eval, and if the distribution is discrete (Poisson, Categorical, Binomial, NegativeBinomial family) it casts the value to an integer tensor before evaluating. For anything else it uses a float tensor. One caveat baked into the source: not every torch distribution implements cdf. That's why Gamma, Poisson, and Student's t get scipy-backed Ex subclasses in this pack - so their CDFs work at all.

Inputs that matter

  • distribution - the PTDISTRIBUTION from a Ptd* node.
  • x - the value to evaluate at, as a text literal. 0.5, 10, or a tuple like (0.0, 1.0, 2.0) to evaluate several points at once.

Output is a TENSOR - for a scalar input it's a 0-d tensor containing a probability in [0, 1]; for a tuple it's a vector. Wire it to a text/plot node or compare it against a threshold to make a decision in the graph.

Installing it

Standard pack install. ComfyUI Manager → "Pt Wrapper" → install → restart, or:

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

Then restart ComfyUI. Heavy first install (matplotlib, pandas, scipy, scikit-learn, transformers, datasets, pinned gensim) - scipy matters here because the Student-t and Poisson CDFs rely on it.

Common issues

The x field is the usual text-input trap: it must be a number literal, and if you type something that isn't, the node raises a clear "You need to specify a float or an int." error and refuses to run. If you get a NotImplementedError from a distribution's CDF, you've hit one the pack didn't patch - check you're using a Ptd* constructor rather than some other source of PTDISTRIBUTION. And remember the result is a cumulative probability: it only ever grows as x increases, which is a decent sanity check when your numbers look wrong.

CategoryDistribution

Inputs (2)

NameTypeDefaultDescription
distributionPTDISTRIBUTION
xSTRING

Outputs (1)

NameTypeDescription
TENSORTENSOR