当前位置: 首页>>代码示例>>Python>>正文


Python Constants.aLund方法代码示例

本文整理汇总了Python中Constants.aLund方法的典型用法代码示例。如果您正苦于以下问题:Python Constants.aLund方法的具体用法?Python Constants.aLund怎么用?Python Constants.aLund使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Constants的用法示例。


在下文中一共展示了Constants.aLund方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Getzhitmiss

# 需要导入模块: import Constants [as 别名]
# 或者: from Constants import aLund [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
开发者ID:PyLund-MC,项目名称:PyLund,代码行数:38,代码来源:Stringdecay.py


注:本文中的Constants.aLund方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。