0
我試圖實現R函數ecdf()
。在R中實現ECDF
我正在考慮兩種情況:一種用t
一維,另一種用t
作爲矢量。
#First case
my.ecdf<-function(x,t) {
indicator<-ifelse(x<=t,1,0)
out<-sum(indicator)/length(x)
out
}
#Second case
my.ecdf<-function(x,t) {
out<-length(t)
for(i in 1:length(t)) {
indicator<-ifelse(x<=t[i],1,0)
out[i]<-sum(indicator)/length(t)
}
out
}
我如何檢查我是否在做正確的事的R功能ecdf()
與否?該函數僅作爲參數x
,因此我無法指定值t
。
我知道這一點,但我不認爲它可以幫助我的問題。 – Egodym 2014-12-07 23:47:56