0

I’m a PyMC3 beginner, I started three weeks ago to familiarize myself with it and I’m doing currently a learning work so I have one doubt in my program. Sorry if it is a stupid question.

I have that model:

with pm.Model() as clientes:

  name_clients = pm.Bound(pm.Geometric, upper=100)('nombres_clientes', p=0.02685)
  age_clients = pm.TruncatedNormal('edad.clientes', mu=34, sigma=24, lower=0.0, 
                                   upper=101.0)

As you can see, both distributions are limited between ranges (name_clients between 1 and 100, and age_clients between 0 and 101).

My question is about, how can I know the probability(between 0 and 1), for example, that name_clients is 67 ? And what is the conditional probability if I have age_clients = 21 and name_clients = 34 ?

I was looking a lot of topics and reviews but I don’t have a clear idea about this. If you can help me, I will be very grateful :)

EduardoCabria
  • 29
  • 1
  • 4
  • The (truncated) normal is a continuous distribution, so mathematically `P{age_clients = x} = 0` for all `x`. With continuous random variables you should be asking about probabilities of ranges, not points. – pjs Feb 26 '20 at 23:10
  • You are right ! Thankyou – EduardoCabria Feb 26 '20 at 23:22

1 Answers1

0

You can always estimate probabilities as an expectation:

Pr[X ∈ A] = E[_{A}(X)],

where

_{A}(x) = (x ∈ A) ? 1 : 0

is the indicator function of the set whose probability you want.

So you just have to sample from the joint distribution, map this indictator function over the chain, and get the mean. If the probability you seek is a conditional one, insert the conditioned values as observed values in the model (in PYMC3, you do this by the observed keyword argument, as far as I remember).

Another way would be to work directly with the log-pdf of the model, see here, but that requires handling internals of the PPL you deal with.

phipsgabler
  • 20,535
  • 4
  • 40
  • 60
  • Thankyou so much, you really help me ! Do you know maybe any book or article that can help me in this issue ? Because I need more information. – EduardoCabria Feb 26 '20 at 14:45
  • I can only suggest references for basic MCMC theory. I personally learnt from [this lecture](http://users.jyu.fi/~mvihola/stochsim/), but it's rather mathematical. I don't use PYMC3 myself. – phipsgabler Feb 26 '20 at 14:49