# AIS

## One Simple Way

1. start with a trial density, say $$g\_0(x) = t\_\alpha (x; \mu\_0,\Sigma\_0)$$
2. with weighted Monte Carlo samples, estimate the parameters, mean and covariate matrix, and construct new trial density, say $$g\_1(x) = t\_\alpha (x; \mu\_1,\Sigma\_1)$$
3. construct a certain measure of discrepancy between the trial distribution and the target distribution, such as the coefficient of variation of importance weights, does not improve any more.

## One Example

Implement an Adaptive Importance Sampling algorithm to evaluate mean and variance of a density

$$
\pi(\mathbf{x})\propto N(\mathbf{x;0}, 2I\_4) + 2N(\mathbf{x; 3e}, I\_4) + 1.5 N(\mathbf{x; -3e}, D\_4)
$$

where $$\mathbf{e} = (1,1,1,1), I\_4 = diag(1,1,1,1), D\_4 = diag(2,1,1,.5)$$.

A possible procedure is as follows:

1. start with a trial density $$g\_0 =t\_{\nu}(0, \Sigma)$$
2. Recursively, build

   $$
   g\_k(\mathbf{x})=(1-\epsilon)g\_{k-1}(\mathbf {x}) + \epsilon t\_{\nu}(\mu, \Sigma)
   $$

   in which one chooses $$(\epsilon, \mu, \Sigma)$$ to minimize the variation of coefficient of the importance weights.


---

# 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://mc.hohoweiya.xyz/ais.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.
