# Geometric variable initialization

**URL:** <https://discourse.pymc.io/t/geometric-variable-initialization/1085>\
**Category:** Questions\
**Created:** [April 13, 2018, 10:12pm UTC](https://discourse.pymc.io/t/geometric-variable-initialization/1085 "2018-04-13T22:12:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![redst4r](https://avatars.discourse-cdn.com/v4/letter/r/6a8cbe/32.png) [@redst4r](https://discourse.pymc.io/u/redst4r)\
**Post date:** [April 13, 2018, 10:12pm UTC](https://discourse.pymc.io/t/geometric-variable-initialization/1085/1 "2018-04-13T22:12:36Z")

</div>

Hi,

I saw that geometric variables by default get initialized to 1 (via `self.mode = 1`).  
Any particular reason for that as opposed to the mean (1/p)?

The initialization at 1 creates some problems with the metropolis sampler (especially if the shape `N` of the geometric is \>\> 1): The Metropolis proposal is by default a “discretized” Gaussian, i.e. there’s a good chance that your proposal will take you from [1,1,1,…] to [1,0,1,…], whose loglikelihood is -inf.  
Hence the chain has a real hard time leaving the initial state (if `N` is large, its very likely that one dimension contains the 0 and hence the whole proposal will be discarded).

Whats the general strategy for sampling discrete RVs in PyMC anyway? I’ve seen a few examples of binary RVs, but nothing for general discrete RVs

---

<div class="post-metadata">

**Author:** ![junpenglao](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/junpenglao/32/8_2.png) [@junpenglao](https://discourse.pymc.io/u/junpenglao)\
**Post date:** [April 14, 2018, 7:50am UTC](https://discourse.pymc.io/t/geometric-variable-initialization/1085/2 "2018-04-14T07:50:03Z")

</div>

> [@redst4r](#):
>
> Any particular reason for that as opposed to the mean (1/p)?

If I remember correctly, all discrete RVs default value is at the mode, as the mean could be a continuous value thus outside of the support of the RV.

The inefficiency of random walk metropolis in high dimension is quite well noticed. You can do `testval = 2` to set a different start value for the RV, or pass a dict of start value to `pm.sample()`

PyMC3 assign different samplers to discrete RVs, but besides a few special cases (Bernoulli, Categorical) they are sampled with random walk Metropolis.
