Metropolis–Hastings can estimate an integral of the form of  where formula_90 is a (measurable) function of interest. For example, consider a statistic formula_91 and its probability distribution formula_92, which is a marginal distribution. Suppose that the goal is to estimate formula_92 for formula_94 on the tail of formula_92. Formally, formula_92 can be written as  and, thus, estimating formula_92 can be accomplished by estimating the expected value of the indicator function formula_99, which is 1 when formula_100 and zero otherwise. Because formula_94 is on the tail of formula_92, the probability to draw a state formula_14 with formula_91 on the tail of formula_92 is proportional to formula_92, which is small by definition. The Metropolis–Hastings algorithm can be used here to sample (rare) states more likely and thus increase the number of samples used to estimate formula_92 on the tails. This can be done e.g. by using a sampling distribution formula_38 to favor those states (e.g. formula_109 with formula_110). Suppose that the most recent value sampled is formula_11. To follow the Metropolis–Hastings algorithm, we next draw a new proposal state formula_22 with probability density formula_71 and calculate a value  where  is the probability (e.g., Bayesian posterior) ratio between the proposed sample formula_22 and the previous sample formula_11, and  is the ratio of the proposal density in two directions (from formula_11 to formula_22 and conversely). This is equal to 1 if the proposal density is symmetric. Then the new state formula_121 is chosen according to the following rules. The Markov chain is started from an arbitrary initial value formula_68, and the algorithm is run for many iterations until this initial state is "forgotten". These samples, which are discarded, are known as "burn-in". The remaining set of accepted values of formula_14 represent a sample from the distribution formula_1. The algorithm works best if the proposal density matches the shape of the target distribution formula_1, from which direct sampling is difficult, that is formula_129. If a Gaussian proposal density formula_16 is used, the variance parameter formula_131 has to be tuned during the burn-in period. This is usually done by calculating the "acceptance rate", which is the fraction of proposed samples that is accepted in a window of the last formula_132 samples.