DRAM¶
Delayed Rejection Adaptive Metropolis (Haario et al. 2006).
Combines:
- Adaptive Metropolis (AM): empirical covariance adaptation.
- Delayed Rejection (DR): when the first proposal is rejected, try a second, smaller proposal with a Tierney-Mira corrected acceptance probability.
DRAM is the recommended general-purpose adaptive sampler — it is robust to poor initialisation and handles correlated posteriors well.
import numpy as np
import mcmckit as mc
sampler = mc.DRAM(
n_samples=15_000,
initial_cov=np.eye(2) * 0.5,
dr_scale=0.1, # second proposal = dr_scale × first
adapt_start=200, # start adapting after this many steps
)
result = sampler.run(problem, x0=[0.0, 0.0])
print(f"stage-1 acc: {sampler.stage1_acceptance_rate:.3f}")
print(f"stage-2 acc: {sampler.stage2_acceptance_rate:.3f}")
DRAM ¶
Bases: BaseSampler
Delayed Rejection Adaptive Metropolis (DRAM) sampler.
Combines two ideas:
Adaptive Metropolis (AM): the proposal covariance is updated during sampling using the empirical covariance of all past samples, targeting the theoretically optimal scaling 2.38²/d.
Delayed Rejection (DR): when the first proposal is rejected, a second (smaller) proposal is attempted instead of immediately staying put. The second-stage acceptance criterion accounts for the fact that the first proposal was rejected, preserving detailed balance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_samples
|
int
|
Number of samples to collect when calling run(). |
required |
initial_cov
|
array - like
|
Initial proposal covariance. Scalar, 1D (diagonal), or 2D (full). Defaults to 0.1² * I. |
None
|
adapt_start
|
int
|
Number of samples to collect before starting covariance adaptation. Default 100. |
100
|
adapt_interval
|
int
|
Update the proposal covariance every this many steps. Default 10. |
10
|
dr_scale
|
float
|
The second-stage proposal uses dr_scale² * C₁. Smaller = more conservative second attempt. Default 0.1. |
0.1
|
regularization
|
float
|
Small diagonal regularization added to the empirical covariance to keep it positive definite. Default 1e-6. |
1e-06
|
References
Haario, H., Laine, M., Mira, A., & Saksman, E. (2006). DRAM: Efficient adaptive MCMC. Statistics and Computing, 16(4), 339-354.
Source code in mcmckit/samplers/dram.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | |
Attributes¶
Methods:¶
step ¶
Perform one DRAM step (two-stage delayed rejection + adaptation).
Source code in mcmckit/samplers/dram.py
run ¶
Initialize and run for n_samples steps, returning a Result.
get_result ¶
Return a Result from all samples collected so far.