Vamos a los datos ordenados se x1≤x2≤⋯≤xnx1≤x2≤⋯≤xn. Para entender el CDF empírica GG, considere uno de los valores de la xixi--vamos a llamar a γγ - y supongo que algunos de número de kk de la xixi son de menos de γγ t≥1t≥1 de la xixi son igual a γγ. Elija un intervalo de [α,β][α,β] en el que, de todos los posibles valores de los datos, sólo γγ aparece. Entonces, por definición, dentro de este intervalo de GG tiene el valor constante k/nk/n para los números de menos de γγ, y salta a la constante valor (k+t)/n(k+t)/n para números mayores a γγ.
![ECDF]()
Considerar la contribución a ∫b0xh(x)dx∫b0xh(x)dx del intervalo de [α,β][α,β]. A pesar de hh no es una función, es un punto de medida de tamaño de la t/nt/n γγ--la integral se define por medio de la integración por partes para convertirla en un honesto a la bondad integral. Vamos a hacer esto en el intervalo de [α,β][α,β]:
∫βαxh(x)dx=(xG(x))|βα−∫βαG(x)dx=(βG(β)−αG(α))−∫βαG(x)dx.∫βαxh(x)dx=(xG(x))|βα−∫βαG(x)dx=(βG(β)−αG(α))−∫βαG(x)dx.
The new integrand, although it is discontinuous at γγ, is integrable. Its value is easily found by breaking the domain of integration into the parts preceding and following the jump in GG:
∫βαG(x)dx=∫γαG(α)dx+∫βγG(β)dx=(γ−α)G(α)+(β−γ)G(β).∫βαG(x)dx=∫γαG(α)dx+∫βγG(β)dx=(γ−α)G(α)+(β−γ)G(β).
Substituting this into the foregoing and recalling G(α)=k/n,G(β)=(k+t)/nG(α)=k/n,G(β)=(k+t)/n yields
∫βαxh(x)dx=(βG(β)−αG(α))−((γ−α)G(α)+(β−γ)G(β))=γtn.∫βαxh(x)dx=(βG(β)−αG(α))−((γ−α)G(α)+(β−γ)G(β))=γtn.
In other words, this integral multiplies the location (along the XX axis) of each jump by the size of that jump. The size of the jump is
tn=1n+⋯+1ntn=1n+⋯+1n
with one term for each of the data values that equals γγ. Adding the contributions from all such jumps of GG shows that
∫b0xh(x)dx=∑i:0≤xi≤b(xi1n)=1n∑xi≤bxi.∫b0xh(x)dx=∑i:0≤xi≤b(xi1n)=1n∑xi≤bxi.
We might call this a "partial mean," seeing that it equals 1/n times a partial sum. (Please note that it is not an expectation. It can be related to the expectation of a version of the underlying distribution that has been truncated to the interval [0,b]: you must replace the 1/n factor by 1/m where m is the number of data values within [0,b].)
Given k, you wish to find b for which 1n∑xi≤bxi=k. Because the partial sums are a finite set of values, usually there is no solution: you will need to settle for the best approximation, which can be found by bracketing k between two partial means, if possible. That is, upon finding j such that
1nj−1∑i=1xi≤k<1nj∑i=1xi,
you will have narrowed b to the interval [xj−1,xj). You can do no better than that using the ECDF. (By fitting some continuous distribution to the ECDF you can interpolate to find an exact value of b, pero su exactitud dependerá de la precisión del ajuste.)
R
realiza la suma parcial de cálculo con cumsum
y encuentra donde se cruza con cualquier valor especificado utilizando el which
de la familia de las búsquedas, como en:
set.seed(17)
k <- 0.1
var1 <- round(rgamma(10, 1), 2)
x <- sort(var1)
x.partial <- cumsum(x) / length(x)
i <- which.max(x.partial > k)
cat("Upper limit lies between", x[i-1], "and", x[i])
El resultado en este ejemplo de los datos extraídos de alcoholímetro a partir de una distribución Exponencial es
Límite superior se encuentra entre 0.39 y 0,57
El verdadero valor, la resolución de 0.1=∫b0xexp(−x)dx,0.531812. Su proximidad a los resultados sugieren que este código es precisa y correcta. (Simulaciones con mucho más grandes conjuntos de datos de seguir apoyando a esta conclusión).
Aquí está una parcela de la CDF empírica G de estos datos, se estima que el valor del límite superior, se muestra como vertical discontinua gris líneas:
![Figure of ECDF]()