Nowakowski S (2021) Uniqueness of a median of a binomial distribution with rational probability. Advances in Mathematics: Scientific Journal 10(4):1951-1958. (http://dx.doi.org/10.37418/amsj.10.4.9)
Essentially, when p = 0.5 and N is odd, there would be two "median values" (both integer values around N/2). In this case, the median value should be the fully trimmed mid-range, which happens to be equal to the mean value.
Notice that these changes only cope with the untruncated case. For the general truncated case, the solution seems not to be straightforward. In particular, the code below:
For a thorough discussion on this issue, see:
Nowakowski S (2021) Uniqueness of a median of a binomial distribution with rational probability. Advances in Mathematics: Scientific Journal 10(4):1951-1958. (http://dx.doi.org/10.37418/amsj.10.4.9)
Essentially, when p = 0.5 and N is odd, there would be two "median values" (both integer values around N/2). In this case, the median value should be the fully trimmed mid-range, which happens to be equal to the mean value.
Notice that these changes only cope with the untruncated case. For the general truncated case, the solution seems not to be straightforward. In particular, the code below:
will produce value
3
, which is wrong (it should be2.5
).At any rate, this change is bug-compatible with Matlab, thanks to the use of
__traditional_()
.