Module Import alias identifier FunctionDef arguments args defaults body Return UnaryOpUSub AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam defaults body If CompareEq NameLoad Num body Return Call NameLoad Return Call AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str If CompareEq NameLoad Call NameLoad body Return NameLoad orelse If CompareGt NameLoad NameLoad body Return BinOpAdd NameLoad Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr BinOpSub NameLoad NameLoad orelse Return BinOpAdd NameLoad Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr BinOpSub NameLoad NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore Call NameLoad For NameStore NameLoad body Assign NameStore Call NameLoad NameLoad NameLoad Return NameLoad decorator_list
N/A N/A numpy np logzero N/A N/A N/A N/A N/A N/A N/A np inf N/A safe_log N/A N/A x N/A N/A N/A N/A x 0 N/A N/A N/A logzero N/A N/A N/A np log x N/A logsum_pair N/A N/A logx logy N/A N/A N/A 
    Return log(x+y), avoiding arithmetic underflow/overflow.

    logx: log(x)
    logy: log(y)

    Rationale:

    x + y    = e^logx + e^logy
             = e^logx (1 + e^(logy-logx))
    log(x+y) = logx + log(1 + e^(logy-logx)) (1)

    Likewise,
    log(x+y) = logy + log(1 + e^(logx-logy)) (2)

    The computation of the exponential overflows earlier and is less precise
    for big values than for small values. Due to the presence of logy-logx
    (resp. logx-logy), (1) is preferred when logx > logy and (2) is preferred
    otherwise.
     N/A N/A logx N/A logzero N/A N/A logy N/A N/A N/A logx logy N/A N/A N/A logx N/A N/A np log1p N/A N/A np exp N/A logy logx N/A N/A N/A logy N/A N/A np log1p N/A N/A np exp N/A logx logy N/A logsum N/A N/A logv N/A N/A N/A 
    Return log(v[0]+v[1]+...), avoiding arithmetic underflow/overflow.
     N/A res N/A logzero N/A val logv N/A N/A res N/A logsum_pair res val N/A res N/A