Computing CDF using pymc distributions

Hi,
Is there any way we can calculate the cumulative distribution function (CDF) of the data using PyMC distributions? I need the CDF values for the likelihood functions of the archmedian copula. I attempted to use TensorFlow distributions with the TensorFlowOp; however, I encountered numerous errors.I checked some links (python - How to get the Cumulative Distribution Function with PyMC3? - Stack Overflow) but couldn’t fully grasp the concept.

If you have any insights or workarounds for efficiently computing CDF values using all the PyMC distributions, I would greatly appreciate your expertise on this matter.

Thanks,
Alok

pm.logcdf: pymc.logcdf — PyMC 5.10.3 documentation

Hi,
Thanks for your reply. This is the function I was looking for. I am trying to implement it for copula parameter estimation. I understand it performs element-wise operations. I am struggling a bit to implement the CDF function in the code. The code is given below. Please advice how to make this work.

##Data
import random
u =
v =
for i in range(0, 100):
u.append(random.randint(0, 100))
v.append(random.randint(0, 100))

import pymc as pm
import pytensor.tensor as pt

mu = pt.scalar(“mu”)
sd = pt.scalar(“sd”)
rv1 = pm.Normal.dist(mu, sd)
exp_rv1 = pt.exp(rv1)
α1 = pt.scalar(“α1”)
α2 = pt.scalar(“α2”)
rv2 = pm.Gamma.dist(α1, α2)
exp_rv2 = pt.exp(rv2)

with pm.Model() as Model:
mu = pm.Normal(‘mu’, 0, 1)
sd = pm.Gamma(‘sd’,0.01,0.01)
α1 = pm.Gamma(‘α1’, 0.01, 0.01)
α2 = pm.Gamma(‘α2’, 0.01, 0.01)
alpha = pm.Normal(‘alpha’, 0, 5
##
###cdf calculation
u1 = pm.logcdf(exp_rv1, u)
u2 = pm.logcdf(exp_rv1, v)
##
def logp(alpha, u1, u2):
t = -alpha* pm.math.log(u1) - alpha* pm.math.log(u2) - pm.math.log(u1) - pm.math.log(u2) +
pm.math.log(alpha + 1) - 2* pm.math.log(-1 + u2**(-alpha) + u1**(-alpha)) - pm.math.log(-1 + u2**
(alpha) + u1**(-alpha))/alpha
return t
Cop = pm.DensityDist(“Cop”, logp,
observed = {“u”: u ,“v”: v})

with Model:
MAP = pm.find_MAP()
trace_HMC = pm.sample(1000, start = MAP)

There’s a shiny new example notebook showing how to do copulas, maybe it will be helpful to look at?