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

Ptdm Icdf Tensor

Ptdm Icdf Tensor — invert a distribution for a whole batch of probabilities

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

PtdmIcdf turns one probability into a value. PtdmIcdfTensor does the same for an entire tensor of probabilities in a single pass - which is exactly what you want when you've got a grid of quantiles to map back into distribution space, or a tensor of p-values you need to convert into concrete cutoffs. It's the vectorized version of the quantile node, and once you need it, you need it.

It's part of ComfyUI-Pt-Wrapper, HowToSD's no-code PyTorch toolkit. The Ptdm* Tensor variants exist precisely because this pack's data-science workflows tend to produce tensors of values, and evaluating point-by-point through the string-input nodes would be miserable. This is the clean batch path.

How it works

No parsing, no branching: it just calls distribution.icdf(tens) and hands back the result. The input tensor of probabilities flows straight into the distribution's inverse CDF, and the output tensor matches the input shape. The real machinery lives in the distribution you built upstream - PtdNormal and PtdUniform do this natively, while the pack's scipy-backed Ex subclasses (Gamma, Poisson, Student-t) patch in what torch lacks.

Inputs that matter

  • distribution - a PTDISTRIBUTION from a Ptd* constructor.
  • tens - a TENSOR of probabilities in [0, 1] to invert.

Output is a TENSOR of the same shape, containing the distribution values at each probability. Feed it a tensor like (0.025, 0.5, 0.975) and you get a full set of percentile bounds back in one go - a quick way to build confidence-interval visuals.

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. The pack's requirements are heavy (matplotlib, pandas, scipy, scikit-learn, transformers, datasets, pinned gensim) so the first install takes a while - nothing downloads model files for the distribution nodes.

Common issues

Same fundamental constraint as its scalar sibling: every probability in the tensor must be inside [0, 1]. Values outside that range produce nan or inf depending on the distribution, and it can be hard to spot which element caused it in a big tensor. Check your inputs upstream. And if you see NotImplementedError, the distribution you're inverting isn't one the pack patched - stick to the Ptd* constructors and the scipy shims will do their thing.

CategoryDistribution

Inputs (2)

NameTypeDefaultDescription
distributionPTDISTRIBUTION
tensTENSOR

Outputs (1)

NameTypeDescription
TENSORTENSOR