本文整理汇总了Python中Constants.bLund方法的典型用法代码示例。如果您正苦于以下问题:Python Constants.bLund方法的具体用法?Python Constants.bLund怎么用?Python Constants.bLund使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Constants
的用法示例。
在下文中一共展示了Constants.bLund方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Getzhitmiss
# 需要导入模块: import Constants [as 别名]
# 或者: from Constants import bLund [as 别名]
def Getzhitmiss(self,string,kperp,mhad):
''' function used to generate a sensible z value based on a hit or miss rejection basis '''
''' Get the constants to be used '''
M = string.Getstringmass()
m_T = numpy.sqrt(kperp*kperp + mhad*mhad) #
z_low = (mhad*mhad + kperp*kperp) / (M*M) # M is the string mass TRYING THE SYTEM WITH TRANS MASS
z_high = 1 - kperp*kperp/(M*M)
a = Constants.aLund()
b = Constants.bLund()
''' Calculate the f_max or g(x) '''
def f(z):
return (1/z)*((1-z)**a)*numpy.exp(-b*m_T*m_T/z)
z_max = scipy.optimize.fminbound(lambda z: -f(z), z_low, z_high)
z_max = z_max*1.01
g_z = (1/z_max)*((1-z_max)**a)*numpy.exp(-b*m_T*m_T/z_max) # this is taken as g(x) (its a constant)
Constant = g_z # a reminder that g(z) here used is a constant. The maximum value that f(z) can take
G_z_max = z_high * g_z
G_z_min = z_low * g_z
''' create the iterative loop to find a suitable z value, based on hit or miss principle '''
while True:
rand_no_1 = numpy.random.uniform(0,1) #(z_low,z_high) # this number used to calculate X test
rand_no_2 = numpy.random.uniform(0,1) #(z_low,z_high) # this number used to accept / reject with given probability, as compared to a test value
z_test = (rand_no_1*(z_high-z_low) + z_low) #/ Constant
f_z_test = (1/z_test)*((1-z_test)**a)*numpy.exp(-b*m_T*m_T/z_test)
g_z_test = Constant # constant as listed above
testvalue = f_z_test / g_z_test
if rand_no_2 <= testvalue:
return z_test
break
else:
continue