當前位置: 首頁>>代碼示例>>Python>>正文


Python math.expm1方法代碼示例

本文整理匯總了Python中math.expm1方法的典型用法代碼示例。如果您正苦於以下問題:Python math.expm1方法的具體用法?Python math.expm1怎麽用?Python math.expm1使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在math的用法示例。


在下文中一共展示了math.expm1方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: calculate_sync_order

# 需要導入模塊: import math [as 別名]
# 或者: from math import expm1 [as 別名]
def calculate_sync_order(oscillator_phases):
        """!
        @brief Calculates level of global synchronization (order parameter) for input phases.
        @details This parameter is tend 1.0 when the oscillatory network close to global synchronization and it tend to 0.0 when 
                  desynchronization is observed in the network.
        
        @param[in] oscillator_phases (list): List of oscillator phases that are used for level of global synchronization.
        
        @return (double) Level of global synchronization (order parameter).
        
        @see calculate_order_parameter()
        
        """

        exp_amount = 0.0
        average_phase = 0.0

        for phase in oscillator_phases:
            exp_amount += math.expm1(abs(1j * phase))
            average_phase += phase

        exp_amount /= len(oscillator_phases)
        average_phase = math.expm1(abs(1j * (average_phase / len(oscillator_phases))))

        return abs(average_phase) / abs(exp_amount) 
開發者ID:annoviko,項目名稱:pyclustering,代碼行數:27,代碼來源:sync.py

示例2: test_pure_python_math_module

# 需要導入模塊: import math [as 別名]
# 或者: from math import expm1 [as 別名]
def test_pure_python_math_module(self):
        vals = [1, -.5, 1.5, 0, 0.0, -2, -2.2, .2]

        # not being tested: math.asinh, math.atanh, math.lgamma, math.erfc, math.acos
        def f():
            functions = [
                math.sqrt, math.cos, math.sin, math.tan, math.asin, math.atan,
                math.acosh, math.cosh, math.sinh, math.tanh, math.ceil,
                math.erf, math.exp, math.expm1, math.factorial, math.floor,
                math.log, math.log10, math.log1p
            ]
            tr = []
            for idx1 in range(len(vals)):
                v1 = vals[idx1]
                for funIdx in range(len(functions)):
                    function = functions[funIdx]
                    try:
                        tr = tr + [function(v1)]
                    except ValueError as ex:
                        pass

            return tr

        r1 = self.evaluateWithExecutor(f)
        r2 = f()
        self.assertGreater(len(r1), 100)
        self.assertTrue(numpy.allclose(r1, r2, 1e-6)) 
開發者ID:ufora,項目名稱:ufora,代碼行數:29,代碼來源:MathTestCases.py

示例3: _log1mexp

# 需要導入模塊: import math [as 別名]
# 或者: from math import expm1 [as 別名]
def _log1mexp(x):
  """Numerically stable computation of log(1-exp(x))."""
  if x < -1:
    return math.log1p(-math.exp(x))
  elif x < 0:
    return math.log(-math.expm1(x))
  elif x == 0:
    return -np.inf
  else:
    raise ValueError("Argument must be non-positive.") 
開發者ID:itsamitgoel,項目名稱:Gun-Detector,代碼行數:12,代碼來源:core.py

示例4: stop

# 需要導入模塊: import math [as 別名]
# 或者: from math import expm1 [as 別名]
def stop(self):
        super(Returns, self).stop()

        if not self._fundmode:
            self._value_end = self.strategy.broker.getvalue()
        else:
            self._value_end = self.strategy.broker.fundvalue

        # Compound return
        try:
            nlrtot = self._value_end / self._value_start
        except ZeroDivisionError:
            rtot = float('-inf')
        else:
            if nlrtot < 0.0:
                rtot = float('-inf')
            else:
                rtot = math.log(nlrtot)

        self.rets['rtot'] = rtot

        # Average return
        self.rets['ravg'] = ravg = rtot / self._tcount

        # Annualized normalized return
        tann = self.p.tann or self._TANN.get(self.timeframe, None)
        if tann is None:
            tann = self._TANN.get(self.data._timeframe, 1.0)  # assign default

        if ravg > float('-inf'):
            self.rets['rnorm'] = rnorm = math.expm1(ravg * tann)
        else:
            self.rets['rnorm'] = rnorm = ravg

        self.rets['rnorm100'] = rnorm * 100.0  # human readable % 
開發者ID:mementum,項目名稱:backtrader,代碼行數:37,代碼來源:returns.py

示例5: expm1

# 需要導入模塊: import math [as 別名]
# 或者: from math import expm1 [as 別名]
def expm1(x=('FloatPin', 0.1)):
        '''Return `e**x - 1`. For small floats `x`, the subtraction in `exp(x) - 1` can result in a significant loss of precision.'''
        return math.expm1(x) 
開發者ID:wonderworks-software,項目名稱:PyFlow,代碼行數:5,代碼來源:MathLib.py

示例6: log1m_exp

# 需要導入模塊: import math [as 別名]
# 或者: from math import expm1 [as 別名]
def log1m_exp(val):
    """Numerically stable implementation of `log(1 - exp(val))`."""
    if val >= 0.:
        return nan
    elif val > LOG_2:
        return log(-expm1(val))
    else:
        return log1p(-exp(val)) 
開發者ID:matt-graham,項目名稱:mici,代碼行數:10,代碼來源:utils.py

示例7: expm1

# 需要導入模塊: import math [as 別名]
# 或者: from math import expm1 [as 別名]
def expm1(node): return merge([node], math.expm1) 
開發者ID:maxim5,項目名稱:hyper-engine,代碼行數:3,代碼來源:sugar.py


注:本文中的math.expm1方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。