# Skip/nth Sampling in Turing / Thinning

**URL:** <https://discourse.julialang.org/t/skip-nth-sampling-in-turing-thinning/89829>\
**Category:** General Usage\
**Tags:** turing\
**Created:** [November 5, 2022, 10:47pm UTC](https://discourse.julialang.org/t/skip-nth-sampling-in-turing-thinning/89829 "2022-11-05T22:47:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dlakelan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dlakelan/32/8491_2.png) [@dlakelan](https://discourse.julialang.org/u/dlakelan)\
**Post date:** [November 5, 2022, 10:47pm UTC](https://discourse.julialang.org/t/skip-nth-sampling-in-turing-thinning/89829/1 "2022-11-05T22:47:52Z")

</div>

I’ve got a situation where I’m trying to select a set of “discriminators” from among a large number of things… so I want a vector of either -1,0,1 which when dotted with a vector of 0,1 (absent,present) gives a “score” that i can use like a logit.

Since this is a discrete distribution I’m doing MH() sampling, and I want to do a very large number of samples, like 1M but I want to keep only every 100th sample or something. In the end I’d have 10k samples but hopefully much less autocorrelated than if I had just done 10k samples.

```julia
sample(model, MH(),1_000_000; skip=100) #or something

```

How can I make Turing keep only every 100th sample?

There doesn’t seem to be anything in the docs?

EDIT: by reading the code I see there’s a “thin” option? is this the right thing? If so, is there somewhere this is described in the docs? If not, where should it go, I’ll do a PR.

```julia
sam = sample(fmmodel,MH(),50000; discard_initial=2000,thinning=20)

```

For example, looks like the options I’m looking for are “thinning” and “discard\_initial”

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [November 6, 2022, 7:49am UTC](https://discourse.julialang.org/t/skip-nth-sampling-in-turing-thinning/89829/2 "2022-11-06T07:49:48Z")

</div>

> [@dlakelan](#):
>
> is there somewhere this is described in the docs?

It can be found in [AbstractMCMC](https://turinglang.github.io/AbstractMCMC.jl/dev/api/#Common-keyword-arguments), which hosts the sampling interface for Turing:

`thinning` (default: `1`): factor by which to thin samples.
