Library: | distribs |
See also: | plothist |
Quantlet: | empcdf | |
Description: | computes the empirical cdf from a vector of observations. |
Usage: | {x,y} = empcdf(d{,infsupport,step,noxsort}) | |
Input: | ||
d | n x 1 vector, observations | |
infsupport | optional scalar, infimum of the support of the distribution (default: -Inf); enter NaN if you want to omit it | |
step | optional scalar, if zero (default), the output contains the unique jump points and the corresponding values of the empirical cdf; if non-zero, values at the jump points range from the previous to the current value of the empirical cdf so that one can directly plot a step function | |
noxsort | optional scalar, if non-zero, vector x equals d and y contains the appropriately assigned values (0 by default); step and infsupport parameters are ignored | |
Output: | ||
x | m x 1 vector, x-values ascendingly sorted unless noxsort is non-zero | |
y | m x 1 vector, values of the empirical cdf corresponding to x |
library("distribs") library("plot") randomize(0) d = uniform(10) {x,y} = empcdf(d,0) x ~ y {x,y} = empcdf(d,0,1) line(x~y) ; cdf
Plots of the empirical distribution and outputs Contents of _tmp [ 1,] 0 0 [ 2,] 1.1156e-07 0.1 [ 3,] 0.0030269 0.2 [ 4,] 0.0035468 0.3 [ 5,] 0.12478 0.4 [ 6,] 0.23159 0.5 [ 7,] 0.26201 0.6 [ 8,] 0.42072 0.7 [ 9,] 0.42981 0.8 [10,] 0.60488 0.9 [11,] 0.61585 1
library("distribs") library("plot") d = #(1,2,3,2,4,1,1,5,3,5,2,1,5,1,3,2) {x,y} = empcdf(d,0) x ~ y {x,y} = empcdf(d,0,0,1) x ~ y {x,y} = empcdf(d,0,1) line(x~y) ; cdf
Plots of the empirical distribution and outputs Contents of _tmp [1,] 0 0 [2,] 1 0.3125 [3,] 2 0.5625 [4,] 3 0.75 [5,] 4 0.8125 [6,] 5 1 Contents of _tmp [ 1,] 1 0.3125 [ 2,] 2 0.5625 [ 3,] 3 0.75 [ 4,] 2 0.5625 [ 5,] 4 0.8125 [ 6,] 1 0.3125 [ 7,] 1 0.3125 [ 8,] 5 1 [ 9,] 3 0.75 [10,] 5 1 [11,] 2 0.5625 [12,] 1 0.3125 [13,] 5 1 [14,] 1 0.3125 [15,] 3 0.75 [16,] 2 0.5625