خرید بک لینک

Vote count: 0

I am calling a function which computes and retu some value. The expression has two parts to it, as seen below:

def fSMHM(x, alpha, delta, gamma) : 
    #cst is some constant value
    val = cst + delta*((np.log10(1+np.exp(x)))**gamma)/(1+np.exp(10**(-x)))
    retu val

fSMHM(np.log10(Mh/m1), alpha, delta, gamma)

For x << 1, the denominator of the second term becomes extremely large (i.e, the term 1+np.exp(10**(-x))), and yields an overflow. I would like to handle cases that yield an overflow by simply retuing the first term. Is there a way to do this? I tried using a try-except like:

def fSMHM(x, alpha, delta, gamma) : 
    #cst is some constant value
    try: 
       val = cst + delta*((np.log10(1+np.exp(x)))**gamma)/(1+np.exp(10**(-x)))
    except: 
       val = cst
    retu val

But this did not work... Instead, an overflow error was still raised. Thanks in advance :)

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: يکشنبه 16 خرداد 1395 ساعت: 8:49

صفحه بندی