# Suggestion about sampling methods

**URL:** <https://discourse.pymc.io/t/suggestion-about-sampling-methods/1670>\
**Category:** Development\
**Created:** [August 7, 2018, 6:53pm UTC](https://discourse.pymc.io/t/suggestion-about-sampling-methods/1670 "2018-08-07T18:53:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rpgoldman](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/rpgoldman/32/1800_2.png) [@rpgoldman](https://discourse.pymc.io/u/rpgoldman)\
**Post date:** [August 7, 2018, 6:53pm UTC](https://discourse.pymc.io/t/suggestion-about-sampling-methods/1670/1 "2018-08-07T18:53:16Z")

</div>

It looks like the three sampling methods all treat their vars arguments differently. `sample_posterior_predictive` wants an iterable of `Distribution` objects. `sample_prior_predictive` wants a list of variable _names_ (strings). `sample` doesn’t take any `vars` argument (or only to pass through to somewhere else – I didn’t chase this down carefully enough).  
The clash in argument type between posterior and prior predictive seems unnecessary and it’s a pain for the programmer.  
I’m willing to submit a PR given a little guidance about which is best to use. Ideally, I think it would be great to have a general protocol for passing `vars` arguments.

---

<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:** [August 7, 2018, 7:59pm UTC](https://discourse.pymc.io/t/suggestion-about-sampling-methods/1670/2 "2018-08-07T19:59:08Z")

</div>

Indeed currently there are some inconsistencies of API (eg., see long discussion in [https://github.com/pymc-devs/pymc3/pull/3119#issuecomment-408404682](https://github.com/pymc-devs/pymc3/pull/3119#issuecomment-408404682))

I think to make all API consistence, I would pass variable _names_ to `sample_*` functions as a general protocol. However, for sampling the option passing vars should not be removed for backward compatibility.

---

<div class="post-metadata">

**Author:** ![rpgoldman](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/rpgoldman/32/1800_2.png) [@rpgoldman](https://discourse.pymc.io/u/rpgoldman)\
**Post date:** [August 7, 2018, 8:22pm UTC](https://discourse.pymc.io/t/suggestion-about-sampling-methods/1670/3 "2018-08-07T20:22:26Z")

</div>

Right. I think the two functions should both accept either an iterable of variables or of variable names (the Common Lisp spec would refer to this as an iterable of “variable designators”), and then internally they can translate one way or the other, as preferred. I suppose one could even accept a dictionary of names to variables, since that’s what `named_vars` holds.

There should be one or more library functions that will regularize these arguments to either an iterable of names or an iterable of variables.
