# Sampling-Based Inference

Let's say you have some probabilistic model and want to do some inference. You the problem is intractable and are you not able to find analytical solution for it. What would you do?

Simple, generate samples based on your distribution and check what behaviour of your samples for inference.&#x20;

## Monte Carlo Sampling

the samples are independent of each other, as in the coin toss example above. These algorithms are called Monte Carlo methods.

## Markov Chain Monte Carlo (MCMC)

For problems with many variables, generating good quality independent samples is difficult, and therefore, we generate *dependent* samples, that is, each new sample is random, but close to the last sample. Such algorithms are called Markov Chain Monte Carlo (MCMC) methods, because the samples form a “Markov chain”.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://theshank.gitbook.io/ai/probability-and-statistics-1/inference/sampling-based-inference.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
