python xarray – PyMC3/Arviz: CDF value from trace

I have a sample from PyMC3 and I’m trying to get a cumulative probability from it, e.g. P(X < 0). I currently use this:

trace = pymc3.sample(return_inferencedata=True)
prob_x_lt_zero = (trace.posterior.X < 0).sum() / trace.posterior.X.size

Is there a better way to do this, either with some helper function from Arviz or XArray?

I haven’t found any .cdf() method or anything similar.
It’s weird that such basic functions are missing, but more advanced ones are there, such as trace.posterior.X.quantile().

Read more here: Source link