I need to generate random numbers from A to B, but numbers greater than X must appear in F times more often. X lies between A and b

That is the script

`def shift_rand(a, b, x, f): #??? rnd = [shift_rand(0, 4, 2, 2) for i in range(1000)] for i in range(5): print(i, '-', rnd.count(i))`

should give something like:

`0 - 142 1 - 140 2 - 145 3 - 285 4 - 288`

The decision "in a forehead" too beat the performance:

`def shift_rand(a, b, x, f): m = [] for i in range(a, b + 1): if i <= x: m.append(i) else: for j in range(f): m.append(i) return m[random.randint(0, len(m) - 1)]`

Can someone tell me a more elegant algorithm?

PS: JAPANESE is not important