我创建了函数dyst和dystryb:
dyst<- function(t,x)
{
f<-1
return(f)
}
dystryb<- function(x)
{
x<-sort(x)
s<- numeric(101)
u<-seq(0,1, by = 0.01)
for (t in u)
{
s[t*100+1]<-dyst(t,x)
}
return(s)
}
Run Code Online (Sandbox Code Playgroud)
调用函数后dystryb我得到了这个:
> x<-c(1,2,3,4,5,6,7)
> dystryb(x)
[1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 …Run Code Online (Sandbox Code Playgroud)