# Can't sample from posterior. Error: Log probability evaluates to log(0), i.e. negative infinity

I am trying to denoise N points (CTCP_1,…,CTCP_N) given the noisy inputs (ECTCP_1,…,ECTCP_N). Each point CTCP_i is distributed normally with mean zero and one of C standard deviations gamma_1, …, gamma_C. Conditional on CTCP_i, ECTCP_i is normal with mean CTCP_i and standard deviation beta_i, where the input data
ETSE_i^2 = beta_i^2 + gamma_i^2
I am having difficulty sample from the posterior given this structure. Any help would be greatly appreciated.
Thanks.

``````data {
int<lower=1> N; // Number of data points
int<lower=1> K; // Number of dimensions
int<lower=1> C; // Number of
vector[K] ECTCP[N]; // Input data
vector<lower=0>[K] ETSE[N]; // Estimation error
int<lower=1, upper=C> mem[N]; // Membership for each datapoint, choices from 1 to C
}
parameters {
vector[K] CTCP[N];
vector<lower=0>[K] gamma[N];
cholesky_factor_corr[K] L_Omega; //Cholesky factorization of Area Correlation
}
model {
matrix[K, K] L_ASD[C]; //Area Covariance Cholesky Factor
vector[K] beta[N];

L_Omega ~ lkj_corr_cholesky(1);

for (c in 1:C) {
for (k in 1:K) {
gamma[c][k] ~ std_normal();
}
L_ASD[c] = diag_pre_multiply(gamma[c], L_Omega);
}

for (n in 1:N) {
for (k in 1:K) {
beta[n][k] = sqrt(square(ETSE[n][k])-square(gamma[mem[n]][k]));
}
}

for (n in 1:N) {
CTCP[n] ~ multi_normal_cholesky([0,0]', L_ASD[mem[n]]);
for (k in 1:K) {
ECTCP[n][k] ~ normal(CTCP[n][k], beta[n][k]);
}
}
}
generated quantities { //Like transformed parameters, but included in output
corr_matrix[K] Omega;
Omega = multiply_lower_tri_self_transpose(L_Omega);
}
``````

Edited by @jsocolar for syntax highlighting.

Are you able to either add some print statements or use ReddingStan to see what parameter values lead to the -Inf target?

1 Like