meitei
December 17, 2020, 1:15am
1
Hi All,
In the code below, I am expecting the temp=30 is disaggregated into 3 parts using the CDF.
The Sum of three parts should equal to temp.
However, I find d2>d1 in spite of having a lower percentile (i.e. percentile of d2<d1 so it should have a lower quantile).
I will be glad if you can suggest this or another approached.
Thanks in advance
set.seed(10)
dat=runif(50,0,100)
cdf <- as.data.frame(Ecdf(dat))
colnames(cdf)=c("Temperature","probability")
temp=30
(percentile=predict(loess(cdf$probability ~ cdf$Temperature), temp))
set.seed(1000)
(u1 <- runif(1, 0, percentile))
(d1 <- quantile(ecdf(cdf$Temperature), u1))
d1=as.vector(d1)
percentile2=predict(loess(cdf$probability ~ cdf$Temperature),(temp-d1))
(u2=runif(1, 0, percentile2))
d2 <- ifelse(d1 <= temp,
quantile(ecdf(cdf$Temperature),u2),
0 )
d3 <- temp - (d1 + d2)
what is Ecdf ?
is that a typo of ecdf ?
??
but u2 is higher than u1 ?you havent guaranteed that it wouldnt be.
You use randome numbers...
look at the information plotted, and observe the colours.
set.seed(10)
dat=runif(50,0,100)
cdf <- as.data.frame(Hmisc::Ecdf(dat))
colnames(cdf)=c("Temperature","probability")
temp=30
(percentile=predict(loess(cdf$probability ~ cdf$Temperature), temp))
lines(c(0,100),c(percentile,percentile),col="black")
set.seed(1000)
(u1 <- runif(1, 0, percentile))
lines(c(0,100),c(u1,u1),col="blue")
(d1 <- quantile(ecdf(cdf$Temperature), u1))
points(d1,u1,col="red", pch=2)
d1=as.vector(d1)
percentile2=predict(loess(cdf$probability ~ cdf$Temperature),(temp-d1))
lines(c(0,100),c(percentile2,percentile2),col="red")
(u2=runif(1, 0, percentile2))
lines(c(0,100),c(u2,u2),col="purple")
d2 <- ifelse(d1 <= temp,
quantile(ecdf(cdf$Temperature),u2),
0 )
points(d2,u2,col="red", pch=2)
d3 <- temp - (d1 + d2)
system
Closed
January 7, 2021, 10:12am
4
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed. If you have a query related to it or one of the replies, start a new topic and refer back with a link.