问题是 如何在函数L中使用k函数,同时让L函数返回L0(上一步结果sumup乘上含h分式的最后表达式)
如何找到L的极大值点h0(L的极大值是上限不确定的正数)
多谢各位了。
set.seed(0)
x<-c(rnorm(1000))*100
k<-function(x){
k0<-0.75*(1-x^2)
return(k0)
}
p<-function(h){
sum<-0
pro<-1
for(t in 1:1000){
for(s in 1:1000){
if(abs((x
next //此处报错:“the condition has length > 1 and only the first element will be used”
sum<-sum+k((x
}
pro<-pro*sum
sum<-0
}
return(pro)
}
L<-function(h){
L0<-p(h)*((1/(999*h))^1000)
return(L0)
}
curve(L,from=0,to=10000,n=101)


雷达卡


京公网安备 11010802022788号







