Ptdm Icdf
Ptdm Icdf — the inverse CDF, for going from probability back to value
- distribution
- TENSOR
PtdmIcdf is the reverse of PtdmCdf: you hand it a probability q (a number between 0 and 1) and it hands back the value where the cumulative distribution hits that probability. That's the inverse CDF, aka the quantile function - the thing behind every z-score lookup table and confidence interval you've ever seen. If you want "the value such that 95% of draws fall below it," this is the node.
It's part of ComfyUI-Pt-Wrapper, HowToSD's no-code PyTorch environment. It pairs with a Ptd* constructor, and it's one of the more useful query nodes for turning probabilities into concrete numbers in the graph - computing quantiles, defining cutoff thresholds, or reverse-engineering a distribution's behavior.
How it works
The node parses your q with literal_eval, converts it to a float tensor, and calls distribution.icdf(q). That call is deceptively simple because of all the work done elsewhere: PyTorch's Normal and Uniform implement icdf natively, but Gamma, Poisson, and StudentT don't - the pack's Ex subclasses patch those in using scipy's ppf functions. So PtdmIcdf only works as well as it does because the pack filled torch's gaps.
Inputs that matter
- distribution - a
PTDISTRIBUTIONfrom aPtd*node. - q - the probability, as a text literal between 0 and 1:
0.5for the median,0.95for a 95th percentile. A tuple like(0.025, 0.975)gives you a pair of bounds at once.
Output is a TENSOR with the value(s) at those probabilities. For the median (0.5) of a normal you should get back something very close to loc - a nice self-test.
Installing it
Same as every node in the pack: ComfyUI Manager → search "Pt Wrapper" → install → restart, or:
cd ComfyUI/custom_nodes
git clone https://github.com/HowToSD/ComfyUI-Pt-Wrapper
Then restart ComfyUI. The heavy first install (matplotlib, pandas, scipy, scikit-learn, transformers, datasets, pinned gensim) - and scipy is load-bearing here, since the patched icdf implementations for Gamma, Poisson, and Student-t call into it.
Common issues
The classic mistake is feeding q outside [0, 1]. A probability of 1.5 or -0.2 is undefined - some distributions will return inf or nan, others throw. Keep it in range. Also remember q is a text input: type 0.5, not 50%. And if a distribution you're using throws NotImplementedError on icdf, you've hit one the pack didn't patch - stick to the Ptd* constructors and you're safe.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| distribution | PTDISTRIBUTION | — | |
| q | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| TENSOR | TENSOR | — |