嗨,我坚持使用函数的数值积分.我有这个功能:
Nd_f <- function(a,t) {
theta(t-a)*exp(-l*(1-exp(-a))) }
Run Code Online (Sandbox Code Playgroud)
在下面定义的另一个函数中使用:
Nd <- function(s) {
integrate(Nd_f, lower = 0, upper = s, t=s)$value }
Run Code Online (Sandbox Code Playgroud)
其中,theta()是一个已知的函数.所以,使用这些函数我可以评估Nd(t).但是当我尝试用它绘图时:
plot(Nd(0:500), log="y")
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
积分错误(Nd_theta,lower = 0,upper = s,t = s):函数评估给出错误长度的结果
我不明白我是否可以对t的所有值进行评估,为什么我无法绘制它?
l = 0.025,v = 0.001和
theta <- function(t) { exp(-v*t) }
Run Code Online (Sandbox Code Playgroud)
提前致谢!