Ptdm Pmf Tensor
Ptdm Pmf Tensor — the whole probability histogram, one tensor at a time
- distribution
- tens
- TENSOR
PtdmPmf asks about one outcome. PtdmPmfTensor asks about a whole range at once - feed it a tensor of k values and get back the probability of each. If you want the full probability histogram of a discrete distribution (Poisson, Binomial, Categorical), this is the node: build a range of counts, run them through, plot the result, and you've drawn the distribution's shape in one shot.
It's part of ComfyUI-Pt-Wrapper, HowToSD's no-code PyTorch toolkit. It's the vectorized sibling in the Ptdm* family, and the one you'd actually wire into a visualization: PtArange → PtdmPmfTensor → plot node, and the whole PMF curve appears without a loop or a single line of code.
How it works
It's the thin version: torch.exp(distribution.log_prob(tens)), no parsing, no type branching, output shape matches input shape. The dtype of your input tensor flows straight through. The discrete-vs-continuous handling that the scalar PtdmPmf does with its int64 cast is on you here - feed integer-valued tensors for discrete distributions and it all behaves.
Inputs that matter
- distribution - a
PTDISTRIBUTIONfrom aPtd*constructor (a discrete one, practically speaking). - tens - a
TENSORof outcome counts, e.g.PtArange(0, 20, 1)to see counts 0 through 19.
Output is a TENSOR of probabilities, same shape as the input. Sum it and you should land near 1.0 for a full support range - the classic correctness check.
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. First install pulls the pack's heavy stack (matplotlib, pandas, scipy, scikit-learn, transformers, datasets, pinned gensim); nothing extra needed for this node.
Common issues
Dtype is the quiet gotcha here. If you feed a float tensor into a discrete distribution's PMF, the values still come back, but you're outside the intended contract - build your k range as ints. And keep the range sensible for your distribution's rate: a Poisson with rate 3 has essentially zero probability mass past 20, so a PtArange out to 100 produces a wall of zeros. That's correct, just useless. Zoom in to where the mass actually lives.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| distribution | PTDISTRIBUTION | — | |
| tens | TENSOR | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| TENSOR | TENSOR | — |