Hi Francois-- I'm not sure I understand your s function.
mindist works by selecting beta so that the sum of the exponentials in the denominator can be approximated by the term corresponding to the smallest value of the distance
(max of beta/x).
Using the same strategy, I would say that maxdist = beta* log(sum(exp(x/beta))
would be a better choice, but you'd have to write new code for it (as far as I know).
however, using a negative beta in mindist also seems to work.
for instance, if x is all integers between 1 and 40
-5000/log(sum(exp(-5000/x))) =40.01316
.2*log(sum(exp(x/.2))) = 40.00135
I think the two functions have a different range of accuracy for a given beta, so you should experiment with the process you are trying to describe and see which is better for you particular case.
I hope this helps
Davide