# How to convert a list of integers into a probability distribution such that the smaller the integer the larger the probability value?

I currently have a list of integers that I'd like to convert into a probability distribution. My goal is to assign lower integer values to higher probability values. What I've come up with so far is something like (in Python code):

>>> original_list = list(range(0, 20))
[0, 1, 2, 3, 4, 5, ..., 19, 20]
>>> preliminary_results = [1 / (x + 0.00001) for x in original_list]
[99999.99, 0.99, 0.49, 0.33, 0.24, 0.19, ..., 0.05]
>>> final_results = [x / sum(preliminary_results) for x in preliminary_results]
[0.99, 9.99e-08, 4.99-08, 5.2629e-07]


The actual output was modified to enhance readability, but I think the message comes across.

As you can see, the strategy works the way I want but I'm wondering if there could be a better way to do this without having to go through two steps, as this is also a bit unintuitive to express mathematically. Thanks.

• sample(original_list,n,rep=TRUE,prob=original_list) Nov 2, 2020 at 7:11
• Take any convergent series with nonnegative terms. Order the terms in decreasing order and normalize the series (so the sum equals 1). The terms of the series gives you the probability for each integer.
– Surb
Nov 2, 2020 at 14:24

A simple way would be to use the first $$n$$ terms of the geometric series: if $$0, then

$$1+r+r^2+\dots+r^{n-1} = \frac{1-r^n}{1-r}.$$

So if you assign

$$p_k:=\frac{1-r}{1-r^n}r^k \text{ for }k=0, \dots, n-1,$$

then these probabilities will sum to $$1$$. The parameter $$r$$ lets you tune how quickly the probabilities drop off.

R code:

rr <- c(0.5,0.7)
nn <- 21
(probs <- sapply(rr,function(xx)(1-xx)/(1-xx^nn)*xx^(0:(nn-1))))
colSums(probs)  # yields 1 for both colunms

plot(1:nn,probs[,1],ylim=range(c(0,probs)),las=1,pch=19,cex=1.2,xlab="",ylab="Probability")
points(1:nn,probs[,2],pch=19,cex=1.2,col="red")
legend("topright",col=c("black","red"),pch=19,pt.cex=1.2,legend=paste("r =",rr))