Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试一个问题,但首先我必须绘制r
r
(x+1)(x+2)...(x+n),
是n一个固定的整数。
n
知道如何创建这个例程吗?
如果x大于 -1,这可能通过利用关系来最有效地计算
x
(x + 1)*(x + 2)* ... *(x + n) = Gamma(x+n+1) / Gamma(x+1).
Gamma 是根据它们的对数在内部计算的,因此以 的形式使用这些对数lgamma:
lgamma
f <- function(x, n) exp(lgamma(x+n+1) - lgamma(x+1))
然后可以通过 获得图, curve例如,如下所示
curve
curve(f(x,3), 0, pi)
你想要这样的东西吗?
f <- function(x, n) { return(prod(1/(x+(1:n)))) }