# How to use sample with a posterior model?

**URL:** https://discourse.julialang.org/t/how-to-use-sample-with-a-posterior-model/76588
**Category:** New to Julia
**Tags:** package
**Created:** [February 16, 2022, 8:20pm UTC](https://discourse.julialang.org/t/how-to-use-sample-with-a-posterior-model/76588 "2022-02-16T20:20:37Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![mirror63](https://avatars.discourse-cdn.com/v4/letter/m/7ba0ec/32.png) [@mirror63](https://discourse.julialang.org/u/mirror63)
#### Post date: [February 16, 2022, 8:20pm UTC](https://discourse.julialang.org/t/how-to-use-sample-with-a-posterior-model/76588/1 "2022-02-16T20:20:37Z")

</div>

say I want to sample using

```julia
sample(model, sampling technique(HMC, MH), number of samples),

```

I have a posterior p(x) = 7_exp(-x/4) + 4_exp(-x/6) - 7\*exp(-(x-4)^2/64)

I want to sample using sample function and the posterior. Can anyone give me an example?
