Nodes/ComfyUI-Pt-Wrapper/Ptdm Cdf Tensor
ComfyUI Node

Ptdm Cdf Tensor

Ptdm Cdf Tensor — the same CDF, but vectorized across a whole tensor

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

PtdmCdf evaluates a cumulative distribution function at one value (or a small tuple). PtdmCdfTensor is the version for when that's not enough - it evaluates the CDF at every element of a tensor, in one shot. If you've got a batch of points from a sampling node and want the cumulative probability of each, this is the node you reach for. Same question, one less step.

It's part of ComfyUI-Pt-Wrapper, HowToSD's no-code PyTorch toolkit. The Ptdm* query family is basically "the stats functions, as nodes," and the Tensor variants are the vectorized siblings - when a pipeline produces tensors of values, the scalar-string nodes get tedious fast, and these are the ones that keep the graph clean.

How it works

Mechanically it's the purest node in the family: it just calls distribution.cdf(tens) and returns the result. No literal_eval, no type sniffing, no scipy branch. The distribution decides the dtype from the tensor you feed it, so the discrete-vs-continuous handling happens naturally on the tensor side. Whatever shape your input tensor has, the output tensor has the same shape - a nice, predictable contract.

Inputs that matter

  • distribution - the PTDISTRIBUTION from a Ptd* constructor.
  • tens - a TENSOR of values to evaluate the CDF at. Any shape.

Output is a TENSOR of the same shape, each element in [0, 1]. Wire it into the pack's plotting nodes, feed it to a comparison node, or stack several of these to build a full empirical-distribution check.

Installing it

Standard pack install: ComfyUI Manager → search "Pt Wrapper" → install → restart. Manual:

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

Restart ComfyUI after. First install is slow thanks to the pack's heavy requirements (matplotlib, pandas, scipy, scikit-learn, transformers, datasets, pinned gensim), but this node itself needs nothing beyond what the pack ships.

Common issues

Two things trip people up. First, the CDF is only defined where the distribution is - you can't evaluate it on a tensor whose values fall outside a discrete distribution's support and expect anything meaningful. Second, the "not all distributions implement CDF" caveat carries over from the scalar node: if your distribution isn't a Ptd* constructor that the pack patched with scipy, this node inherits whatever torch does (or doesn't) implement. With the stock PtdNormal/PtdUniform/PtdGamma/PtdPoisson/PtdStudentT constructors you're covered; beyond that, test first.

CategoryDistribution

Inputs (2)

NameTypeDefaultDescription
distributionPTDISTRIBUTION
tensTENSOR

Outputs (1)

NameTypeDescription
TENSORTENSOR