python - Make a number more probable to result from random -


i'm using x = numpy.random.rand(1) generate random number between 0 , 1. how make x > .5 2 times more probable x < .5?

that's fitting name!

just little manipulation of inputs. first set x in range 0 1.5.

x = numpy.random.uniform(1.5) 

x has 2/3 chance of being greater 0.5 , 1/3 chance being smaller. if x greater 1.0, subtract .5 it

if x >= 1.0:     x = x - 0.5 

Comments