Why does the ecdf function return duplicate x values?
13 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Alex Knight
el 24 de Sept. de 2014
Respondida: Huiru Li
el 9 de Abr. de 2020
When calling the ecdf function (empirical cumulative distribution function), why is the first "x" value always duplicated? This means that the first 'F' output is always 0. For example:
Trial>> y = 0:10;
Trial>> [f,x] = ecdf( y );
Trial>> disp(x')
0 0 1 2 3 4 5 6 7 8 9 10
Trial>> y = 5:15;
Trial>> [f,x] = ecdf( y );
Trial>> disp(x')
5 5 6 7 8 9 10 11 12 13 14 15
In other words, the minimum value in the input array always appears twice, but the corresponding F value in the first instance is always 0. Since the ECDF is given by:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/145507/image.png)
...is this correct?
Thanks!
0 comentarios
Respuesta aceptada
Tom Lane
el 24 de Sept. de 2014
This is just for convenience in plotting. Compare these:
>> y = rand(10,1);
>> [f,x] = ecdf(y);
>> subplot(2,1,1); stairs(x,f)
>> subplot(2,1,2); stairs(x(2:end),f(2:end))
Your formula is correct. If you need only the values after each jump in the cdf, you can discard the first value from both x and f.
Más respuestas (1)
Huiru Li
el 9 de Abr. de 2020
y = rand(10,1);
>> [f,x] = ecdf(y);
>> subplot(2,1,1); stairs(x,f)
>> subplot(2,1,2); stairs(x(2:end),f(2:end))
0 comentarios
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!