【发布时间】:2015-04-10 21:54:04
【问题描述】:
我想整合以下关于 t 的函数,下限 = 0 和上限 = t。我可以使用以下代码做到这一点,但我的最终目标是为每个 t 设置一个积分值。即使我使 t 成为一个序列而不是一个值,或者如果我尝试使用 sapply,我仍然无法在 t 的每一步获得积分值。
#initialize constants
kap=-0.1527778
alph0<-6
b<-0
po<-0.01
t<-100
gp_st<-integrate(function(t) (1-alph0/(alph0+b*t)*(1-po^kap))^(1/kap),lower=0,upper=t)$value
#try alternate where t is now a sequence
t<-seq(1:100)
gp_st2<-function(h) sapply(h,gp_st) #still gives length of 1
谢谢!
【问题讨论】:
标签: r function apply integrate