I created functions dyst
and 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)
}
After calling function dystryb
I get this:
> 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 1 1 1 1 1 1 1 1
[51] 1 1 1 1 1 1 1 1 0 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 1 1 1 1 1 1 1 1 1 1 1
[101] 1
Why isn't this function working for argument 30 and 59 ? Of course it is not about making a functions, which make vector of "1", but I wanted to make it clear, where the problem is.
The following shows exactly what happened, you will have zeros at the locations 15, 29,... because of floating point precision error.
which(seq(0,1, by = 0.01)*100+1 != 1:101)
# [1] 15 29 30 56 57 58 59
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With