Minor changes to the sample_val() to match the indices of z_k