Hi all, I have a question regarding getting samples from Beta distribution in the log space. I want to make the model numerically stable and so I want to have everything in the log space. So, the general idea that I want to implement has two steps: (1) getting samples from Beta, (2) transform samples to the log space and work with them to calculate final target values. So, a toy impl is as follow:
data {
real scale;
real a;
real b;
}
parameters {
real p;
vector<lower=0.0, upper=1.0>[3] labeler_sens[4];
}
transformed parameters {
vector[3] transfomed_labeler_sens[4];
for (i in 1:4) {
transfomed_labeler_sens[i, :] = i * labeler_sens[i, :];
}
}
model {
target += beta_lpdf(p | a, b);
for (i in 1:3) {
target += beta_lpdf(labeler_sens[:,i] | scale * p, scale * (1 - p));
}
}
Now my questions is how I can get Beta samples (I mean p and labeler_sens) in the log space to avoid working with probabilities all together? If I was able to do that, the transformed parameters block will be changed as follow and so I have no variable as a probability:
transformed parameters {
vector[3] log_transfomed_labeler_sens[4];
for (i in 1:4) {
log_transfomed_labeler_sens[i, :] = log(i) + log_labeler_sens[i, :];
}