@@ -51,8 +51,6 @@ CDF <- R6Class(
5151 private = list (
5252 .name = " Inference on Cumulative Distribution Function" ,
5353
54- .lims_for_plot = NULL ,
55-
5654 .preprocess = function () {
5755 super $ .preprocess()
5856
@@ -83,18 +81,13 @@ CDF <- R6Class(
8381 dkw = sqrt(log(2 / alpha ) / (2 * n ))
8482 )
8583
86- lower <- F_n - delta_n
87- upper <- F_n + delta_n
84+ lower <- pmax( F_n - delta_n , 0 )
85+ upper <- pmin( F_n + delta_n , 1 )
8886
8987 private $ .conf_int <- list (
9088 lower = stepfun(private $ .data , lower ),
9189 upper = stepfun(private $ .data , upper )
9290 )
93-
94- private $ .lims_for_plot <- list (
95- x = c(private $ .data [1 ], private $ .data [n ]),
96- y = c(min(lower ), max(upper ))
97- )
9891 },
9992
10093 .print = function () {
@@ -105,13 +98,15 @@ CDF <- R6Class(
10598 plot.stepfun(
10699 private $ .estimate ,
107100 lty = " solid" , do.points = FALSE ,
108- xlim = private $ .lims_for_plot $ x ,
109- ylim = private $ .lims_for_plot $ y ,
101+ xlim = private $ .data [c(1 , length(private $ .data ))],
102+ xlab = expression(x ),
103+ ylim = c(0 , 1 ),
104+ ylab = expression(F [n ](x )),
110105 main = paste(
111106 " Empirical CDF with" ,
112107 paste0(private $ .conf_level * 100 , " %" ),
113108 " Confidence Bounds"
114- ), xlab = expression( x ), ylab = expression( F [ n ]( x ))
109+ )
115110 )
116111 plot.stepfun(
117112 private $ .conf_int $ lower ,
@@ -149,14 +144,16 @@ CDF <- R6Class(
149144 ) +
150145 ggplot2 :: geom_hline(yintercept = c(0 , 1 ), linetype = " dashed" ) +
151146 ggplot2 :: lims(
152- x = private $ .lims_for_plot $ x , y = private $ .lims_for_plot $ y
147+ x = private $ .data [c( 1 , length( private $ .data ))] , y = c( 0 , 1 )
153148 ) +
154149 ggplot2 :: labs(
150+ x = expression(x ),
151+ y = expression(F [n ](x )),
155152 title = paste(
156153 " Empirical CDF with" ,
157154 paste0(private $ .conf_level * 100 , " %" ),
158155 " Confidence Bounds"
159- ), x = expression( x ), y = expression( F [ n ]( x ))
156+ )
160157 ) +
161158 ggplot2 :: theme(
162159 plot.title = ggplot2 :: element_text(
0 commit comments