标签:rom expec lse int font size == pre span
from sympy import integrate
from sympy.abc import x
import random
#integrate(参数1=概率密度函数,参数2=积分起始点,参数3=积分结束点)
概率密度函数:
a<=x<=medic:2*(x-a)/((b-a)*(c-a))
medic<=x<=6:2*(b-x)/((b-a)*(b-c))
def pro(expect_roi,mina,maxb,medic):
if expect_roi >= mina and expect_roi <= medic:
prob = (1 - integrate(2 * (x - mina) / ((maxb - mina) * (medic - mina)), (x, mina, expect_roi)))
if prob == 1:
prob = random.uniform(0.95, 0.98)
elif expect_roi > medic and expect_roi <= maxb:
prob = 1 - (integrate(2 * (maxb - x) / ((maxb - mina) * (maxb - medic)), (x, medic, expect_roi)) + integrate(
2 * (x - mina) / ((maxb - mina) * (medic - mina)), (x, mina, medic)))
if prob == 0:
prob = random.uniform(0.001, 0.1)
elif expect_roi < mina:
prob = random.uniform(0.9, 0.999)
else:
prob = random.uniform(0.001, 0.1)
print(float(prob))
pro(3,2,10,6)#0.96875
pro(5,2,10,6)#0.71875
pro(7,2,10,6)#0.28125
pro(9,2,10,6)#0.03125
标签:rom expec lse int font size == pre span
原文地址:https://www.cnblogs.com/hapyygril/p/9718111.html