Special(base)
Special()所属R语言包:base
Special Functions of Mathematics
数学中的特殊功能
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Special mathematical functions related to the beta and gamma functions.
β和γ功能有关的特殊的数学函数。
用法----------Usage----------
beta(a, b)
lbeta(a, b)
gamma(x)
lgamma(x)
psigamma(x, deriv = 0)
digamma(x)
trigamma(x)
choose(n, k)
lchoose(n, k)
factorial(x)
lfactorial(x)
参数----------Arguments----------
参数:a, b
non-negative numeric vectors.
非负数值向量。
参数:x, n
numeric vectors.
数字向量。
参数:k, deriv
integer vectors.
整数向量。
Details
详情----------Details----------
The functions beta and lbeta return the beta function and the natural logarithm of the beta function,
职能beta和lbeta返回贝塔函数和贝塔函数的自然对数,
The formal definition is
正式的定义是
(Abramowitz and Stegun section 6.2.1, page 258). Note that it is only defined in R for non-negative a and b, and is infinite if either is zero.
(Abramowitz和Stegun 6.2.1节,第258页)。请注意,它是定义在R非负a和b,是无限的,要么是零。
The functions gamma and lgamma return the gamma function Γ(x) and the natural logarithm of the absolute value of the gamma function. The gamma function is defined by (Abramowitz and Stegun section 6.1.1, page 255)
职能gamma和lgamma返回伽玛函数Γ(x)和伽玛函数的绝对值的自然对数。伽玛函数的定义(Abramowitz和Stegun 6.1.1节,第255页)
for all real x except zero and negative integers (when NaN is returned). There will be a warning on possible loss of precision for values which are too close (within about 1e-8)) to a negative integer less than -10.
所有真正的x零和负整数(当NaN返回)除外。将有可能损失的精确值是太近(内约1e-8))比-10少一个负整数的警告。
factorial(x) (x! for non-negative integer x) is defined to be gamma(x+1) and lfactorial to be lgamma(x+1).
factorial(x)(x!非负整数x)被定义为gamma(x+1)和lfactorial是lgamma(x+1)。
The functions digamma and trigamma return the first and second derivatives of the logarithm of the gamma function. psigamma(x, deriv) (deriv >= 0) computes the deriv-th derivative of ψ(x).
职能digamma和trigamma返回伽玛函数的对数的第一和第二衍生物。 psigamma(x, deriv)(deriv >= 0)计算deriv个ψ(x)衍生。
This is often called the "polygamma" function, e.g. in Abramowitz and Stegun (section 6.4.1, page 260); and higher derivatives (deriv = 2:4) have occasionally been called "tetragamma", "pentagamma", and "hexagamma".
这通常被称为“polygamma”功能,例如: Abramowitz和Stegun(第6.4.1,第260页);和较高的衍生物(deriv = 2:4)偶尔被称为“tetragamma,pentagamma,hexagamma”。
The functions choose and lchoose return binomial coefficients and the logarithms of their absolute values. Note that choose(n,k) is defined for all real numbers n and integer k. For k ≥ 1 it is defined as n(n-1)…(n-k+1) / k!, as 1 for k = 0 and as 0 for negative k. Non-integer values of k are rounded to an integer, with a warning. <br> choose(*,k) uses direct arithmetic (instead of [l]gamma calls) for small k, for speed and accuracy reasons. Note the function combn (package utils) for enumeration of all possible combinations.
职能choose和lchoose返回二项式系数,其绝对值的对数。请注意,choose(n,k)所有n和整数k实数定义。 k ≥ 1它被定义为n(n-1)…(n-k+1) / k!1k = 0和0负k,。 k非整数值四舍五入为整数,警告。参考choose(*,k)小[l]gamma,速度和准确性的原因使用直接的算术运算(而不是k电话)。注意功能combn(包utils)枚举所有可能的组合。
The gamma, lgamma, digamma and trigamma functions are internal generic primitive functions: methods can be defined for them individually or via the Math group generic.
gamma,lgamma,digamma和trigamma职能是内部通用的原始功能:可以定义为他们单独或通过Math组通用方法。
源----------Source----------
gamma, lgamma, beta and lbeta are based on C translations of Fortran subroutines by W. Fullerton of Los Alamos Scientific Laboratory (now available as part of SLATEC).
gamma,lgamma,beta和lbeta是基于由W.尔顿的洛斯阿拉莫斯科学实验室(现在作为SLATEC部分可用)的Fortran子程序Ç翻译。
digamma, trigamma and psigamma are based on
digamma,trigamma和psigamma是基于
Amos, D. E. (1983). A portable Fortran subroutine for derivatives of the psi function, Algorithm 610, ACM Transactions on Mathematical Software 9(4), 494–502.
阿莫斯,D. E.(1983)。便携式的Fortran子程序PSI的功能,算法610的衍生工具,ACM交易在数学软件9(4),494-502。
参考文献----------References----------
The New S Language. Wadsworth & Brooks/Cole. (For <code>gamma</code> and <code>lgamma</code>.)
Handbook of Mathematical Functions. New York: Dover. Chapter 6: Gamma and Related Functions.
参见----------See Also----------
Arithmetic for simple, sqrt for miscellaneous mathematical functions and Bessel for the real Bessel functions.
Arithmetic简单,sqrt杂项和数学函数Bessel真正的贝塞尔函数。
For the incomplete gamma function see pgamma.
对于不完全γ函数pgamma。
举例----------Examples----------
require(graphics)
choose(5, 2)
for (n in 0:10) print(choose(n, k = 0:n))
factorial(100)
lfactorial(10000)
## gamma has 1st order poles at 0, -1, -2, ...[#伽玛有一阶极点,在0,-1,-2 ...]
## this will generate loss of precision warnings, so turn off[#这将生成精密警告损失,所以关闭]
op <- options("warn")
options(warn = -1)
x <- sort(c(seq(-3,4, length.out=201), outer(0:-3, (-1:1)*1e-6, "+")))
plot(x, gamma(x), ylim=c(-20,20), col="red", type="l", lwd=2,
main=expression(Gamma(x)))
abline(h=0, v=-3:0, lty=3, col="midnightblue")
options(op)
x <- seq(.1, 4, length.out = 201); dx <- diff(x)[1]
par(mfrow = c(2, 3))
for (ch in c("", "l","di","tri","tetra","penta")) {
is.deriv <- nchar(ch) >= 2
nm <- paste(ch, "gamma", sep = "")
if (is.deriv) {
dy <- diff(y) / dx # finite difference[有限差分]
der <- which(ch == c("di","tri","tetra","penta")) - 1
nm2 <- paste("psigamma(*, deriv = ", der,")",sep='')
nm <- if(der >= 2) nm2 else paste(nm, nm2, sep = " ==\n")
y <- psigamma(x, deriv=der)
} else {
y <- get(nm)(x)
}
plot(x, y, type = "l", main = nm, col = "red")
abline(h = 0, col = "lightgray")
if (is.deriv) lines(x[-1], dy, col = "blue", lty = 2)
}
par(mfrow = c(1, 1))
## "Extended" Pascal triangle:[#“延期”帕斯卡三角形:]
fN <- function(n) formatC(n, width=2)
for (n in -4:10) cat(fN(n),":", fN(choose(n, k= -2:max(3,n+2))), "\n")
## R code version of choose() [simplistic; warning for k < 0]:[#R的选择代码版本()[简单的警告为k <0]:]
mychoose <- function(r,k)
ifelse(k <= 0, (k==0),
sapply(k, function(k) prod(rr-k+1))) / factorial(k))
k <- -1:6
cbind(k=k, choose(1/2, k), mychoose(1/2, k))
## Binomial theorem for n=1/2 ;[#二项式定理当n = 1/2;]
## sqrt(1+x) = (1+x)^(1/2) = sum_{k=0}^Inf choose(1/2, k) * x^k :[#SQRT(1 + X)=(1 + X)^(1/2)= sum_ {k = 0时} ^ INF选用。(1/2,K)* X ^ K:]
k <- 0:10 # 10 is sufficient for ~ 9 digit precision:[10〜9位精度是足够的:]
sqrt(1.25)
sum(choose(1/2, k)* .25^k)
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|