logAdd(mBPCR)
logAdd()所属R语言包:mBPCR
Overflow-safe computation of the logarithm of a sum
溢出安全计算对数的总和
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Function to compute the logarithm of a sum of small numbers, avoiding overflow.
函数来计算一笔小数目的对数,避免溢出。
用法----------Usage----------
logAdd(x)
参数----------Arguments----------
参数:x
array or matrix containing the logarithm of the terms of the sum. If x is a matrix, the function return the results by column.
数组或矩阵包含对数的总和。 x如果是一个矩阵,函数返回列的结果。
值----------Value----------
If x is an array, the function returns log(sum_i(e^x[i])), otherwise it returns an array containing the results by column.
x如果是一个数组,函数返回log(sum_i(e^x[i])),否则返回一个数组,包含列的结果。
举例----------Examples----------
x <- log(c(0.0001, 0.0003, 0.000006))
y <- logAdd(x)
##verification that the computation is correct[#验证的计算是正确的]
z <- sum(c(0.0001, 0.0003, 0.000006))
z
exp(y)
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|