i'm using numpy.random.rand(1) generate number between 0-1 , values of a , b change depending on number is. how can make probability of x > .5 , x < .5 proportional a , b? if a 75 , b 15 probability of x > .5 5 times more probable x < .5. i'm unsure codes use assign probabilities. have:
a = 100 b = 100 while true: x = numpy.random.rand(1) print x if x < .5: = + 10 b = b - 10 print print b if x > .5: b = b + 10 = - 10 print print b if b1 == 0: print break if b2 == 0: print b break
i'd make 2 calls random: 1 calculate random number between 0 , 0.5 , second determine if number should above 0.5.
for example;
a = 100 b = 100 x = numpy.random.rand(1)/2.0 proportion = a/(1.0*b+a) if numpy.random.rand(1) > proportion: x += 0.5
Comments
Post a Comment