GaussianNoiseLikelihood¶
Wraps a forward model and observed data into a log-likelihood for Gaussian measurement noise.
Supports three modes:
| Mode | noise_std |
marginalise_noise |
Noise in theta? |
|---|---|---|---|
| Fixed σ | float or array | — | No |
| Estimated σ | None |
False |
Yes (log_σ appended) |
| Marginalised σ | None |
True |
No |
Per-channel noise is supported via groups.
import mcmckit as mc
# Fixed scalar noise
ll = mc.GaussianNoiseLikelihood(forward_model, y_obs, noise_std=0.05)
# Estimated noise (last element of theta = log_sigma)
ll = mc.GaussianNoiseLikelihood(forward_model, y_obs)
# Marginalised noise — no noise parameter in theta
ll = mc.GaussianNoiseLikelihood(
forward_model, y_obs,
marginalise_noise=True,
inv_gamma_alpha=2.0,
inv_gamma_beta=0.05**2,
)
# Per-channel (different sigma per measurement type)
ll = mc.GaussianNoiseLikelihood(
forward_model, y_obs,
groups=[[0,1,2], [3,4,5]],
marginalise_noise=True,
inv_gamma_alpha=[2.0, 2.0],
inv_gamma_beta=[0.05**2, 0.10**2],
)
GaussianNoiseLikelihood ¶
Log-likelihood for a forward model with Gaussian observation noise.
Supports scalar or per-channel noise, where a "channel" is a group of observations sharing one noise parameter (e.g. all measurements of the 1st natural frequency form one channel, all measurements of the 2nd natural frequency form another).
Three noise modes
Fixed σ — noise_std is a float or array:
log p(y|θ) = -0.5 · Σᵢ ||rᵢ||² / σᵢ² - nᵢ·log(σᵢ)
Estimated σ — noise_std=None: the last n_channels elements of
theta are [log σ₁, …, log σₖ] and are sampled jointly with the
model parameters.
Marginalised σ — noise_std=None, marginalise_noise=True:
each σᵢ² is given an Inverse-Gamma(αᵢ, βᵢ) prior and integrated out
analytically. Works for any nonlinear forward model:
log p(y|θ) = Σᵢ -(αᵢ + nᵢ/2) · log(βᵢ + 0.5·||rᵢ||²)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
forward_model
|
callable
|
|
required |
y_obs
|
(array - like, shape(n_obs))
|
Observed data (flat vector). |
required |
noise_std
|
float, array-like, or None
|
Fixed noise standard deviation(s). Options:
|
None
|
groups
|
list of array-like of int, or None
|
Index groups defining channels. E.g.::
|
None
|
marginalise_noise
|
bool
|
If |
False
|
inv_gamma_alpha
|
float or array - like
|
Shape parameter(s) α of the Inverse-Gamma prior on σᵢ². Scalar → same for all channels. Default 1.0. |
1.0
|
inv_gamma_beta
|
float or array - like
|
Scale parameter(s) β of the Inverse-Gamma prior on σᵢ². Scalar → same for all channels. Default 1e-4. |
0.0001
|
Examples:
Scalar fixed noise::
ll = GaussianNoiseLikelihood(forward_model=f, y_obs=y, noise_std=0.05)
Per-channel fixed noise (2 frequencies, 4 repetitions each)::
ll = GaussianNoiseLikelihood(
forward_model=f, y_obs=y,
noise_std=[0.05, 0.10],
groups=[[0,1,2,3], [4,5,6,7]],
)
Per-channel estimated noise (2 free log_σ params appended to theta)::
ll = GaussianNoiseLikelihood(
forward_model=f, y_obs=y,
groups=[[0,1,2,3], [4,5,6,7]],
)
# theta = [*model_params, log_sigma_1, log_sigma_2]
Per-channel marginalised noise::
ll = GaussianNoiseLikelihood(
forward_model=f, y_obs=y,
groups=[[0,1,2,3], [4,5,6,7]],
marginalise_noise=True,
inv_gamma_alpha=[2.0, 2.0],
inv_gamma_beta=[0.05**2, 0.10**2],
)
Source code in mcmckit/core/noise.py
6 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 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 | |
Attributes¶
estimate_noise
property
¶
True if log σᵢ are free parameters (last n_channels elements of theta).
n_noise_params
property
¶
Number of free noise parameters appended to theta (0 if fixed/marginalised).
Methods:¶
__call__ ¶
Evaluate log p(y | theta).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
theta
|
array - like
|
|
required |
Returns:
| Type | Description |
|---|---|
float
|
|
Source code in mcmckit/core/noise.py
posterior_sigma ¶
Posterior mean of each σᵢ given model parameters (marginalised mode).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
theta
|
array - like
|
Model parameters only. |
required |
Returns:
| Type | Description |
|---|---|
(ndarray, shape(n_channels))
|
|