Bounds on a specific column of a 2D array

Hi again, first, I would like to thank you for your advice. I do really appreciate it. One remaining question, in one of your answers to this post you point out that a target += -bad^2 * bad_scale; gives the same result as:

This is something that I don’t get, let’s say that bad_scale is 70 (just saying), so bad is going to be bad~normal(0,0.0101)? is that the case, because if it is, I tried it in my approach for giving a prior to the sum squared difference of my problem (which is the only one that seems to help to improve the fit to experimental data), and it simply doesn’t work.

thanks in advance.

Is bad defined as

bad = x_min - x

or

if (x < x_min)
    bad = x_min - x;
else
    bad = 0;

? If you are imposing a lower bound, you might want the second version.

Stan only cares about the log density, not how it’s defined. If bad_scale is a constant, then

log normal(bad | 0, 1 / (sqrt(2) * bad_scale))

  = - 1/2 * [(bad - 0) / (1 / (sqrt(2) * bad_scale))]^2 + const

  = -1/2 * bad^2 * 2 * bad_scale + const

  = bad^2 * bad_scale + const

Stan doesn’t care about the constants.

1 Like