EloiTrenquier 2 weeks ago | flag

Different results are to be expected between truncate(r,a,b) and max(a,min(b,r))
The former will redistribute the truncated odds between bins in [a,b]
The latter will accumulate the odds of being lesser than a to a and those of being greater than b to b
Ex:
r = uniform(9)
r_trunc = truncate(r, 1,5) || r_minmax = max(1,min(5,r))
P(r_trunc=4) = 0.2 = P(r=4)/P(r not in [1,5]) || P(r_minmax=4) = 0.1 = P(r=4)
P(r_trunc=5) = 0.2 = P(r=1)/P(r not in [1,5]) || P(r_minmax=5) = 0.5 = P(r>=5)