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

Ptdm Pdf Tensor

Ptdm Pdf Tensor — draw the whole distribution shape at once

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

The scalar PtdmPdf scores one point on a distribution. PtdmPdfTensor scores a whole tensor of points at once - which is the move you want when you're trying to see the distribution. Generate a dense grid of x-values, run them through this node, plot the output, and you've drawn the PDF curve itself. One wire instead of a loop, and you can finally look at your distribution instead of trusting it.

It's part of ComfyUI-Pt-Wrapper, HowToSD's no-code PyTorch toolkit. The Ptdm* Tensor variants exist for exactly this: the pack's plotting and data-analysis workflows run on tensors, and this is the node that turns a distribution into plottable data.

How it works

Thin to the point of transparency: it calls torch.exp(distribution.log_prob(tens)) and returns the result. No parsing, no dtype branching - the tensor's dtype is what it is, and the output keeps the input's shape. The exp-of-log_prob route is the numerically stable way to compute density, same trick as the scalar PDF node. If your distribution doesn't support what you're asking (the pack's source notes PDF isn't available for every torch distribution), you'll find out at this step.

Inputs that matter

  • distribution - a PTDISTRIBUTION from a Ptd* constructor.
  • tens - a TENSOR of points to evaluate. For a curve, feed it a PtArange grid covering a few standard deviations around the mean.

Output is a TENSOR of the same shape containing densities at each point. Pipe it into the pack's plot nodes and you've got the curve.

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

Restart ComfyUI after. Heavy first install (matplotlib, pandas, scipy, scikit-learn, transformers, datasets, pinned gensim); nothing model-related for this node.

Common issues

Remember the values are densities, not probabilities - above 1 at the peak is normal. And when you generate the grid, make sure your PtArange step is fine enough to resolve the curve; a step too large turns a bell into a series of disconnected dots. If the output looks jagged or flat, check your grid resolution before you blame the node.

CategoryDistribution

Inputs (2)

NameTypeDefaultDescription
distributionPTDISTRIBUTION
tensTENSOR

Outputs (1)

NameTypeDescription
TENSORTENSOR