Created
July 22, 2025 14:05
-
-
Save WardBrian/8fea79bd8a765636395ae99748dd6d62 to your computer and use it in GitHub Desktop.
Multimodal model with a neat coding style
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"D": 2, | |
"r": 2.5, | |
"p": 0.6666666666666666 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
D = 2 | |
r = 2.5 | |
p = 2.0 / 3.0 | |
data = {'D': D, 'r': r, 'p': p} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
functions { | |
real mm_lpdf(vector y, real r, real p, int D) { | |
real lp = 0; | |
for (d in 1 : D) { | |
real lp1 = lp + normal_lupdf(y[d] | r, 1); | |
real lp2 = lp + normal_lupdf(y[d] | -r, 1); | |
lp = log_mix(p, lp1, lp2); | |
} | |
return lp; | |
} | |
} | |
data { | |
int<lower=0> D; // number of dimensions | |
real<lower=0> r; // modes in {-r, r}^D | |
real<lower=0, upper=1> p; // p = Pr[Y[d] > 0] | |
} | |
parameters { | |
vector[D] y; | |
} | |
model { | |
y ~ mm(r, p, D); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"title":"Multimodal","dataSource":"generated_by_python"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"num_chains":4,"num_warmup":1000,"num_samples":1000,"init_radius":2} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment