English: This is a visualization of an empirical distribution function. The grey bars show the samples corresponding to the ECDF and the green line is the theoretical distribution from which the samples have been drawn.
%This is Matlab code to generate a visualization of the empirical%distribution function%This code released under the CC0 "license"%Generate random samplesNumSamps=20;%Get standard normally distributed samplessamples=randn(NumSamps,1);%Get emprical cdf[f,x]=ecdf(samples);%Get real cdfx_cdf=[-5:0.01:5];y_cdf=normcdf(x_cdf);%Generate figure;figure;holdon;plot(x_cdf,y_cdf,'-','Color',[0.60.60.6],'LineWidth',2);stairs(x,f,'b-','LineWidth',2);%The 1/NumSamps ensures the black bars are scaled to be probabilitiesplot([samplessamples]',[zeros(NumSamps,1)(1/NumSamps)*ones(NumSamps,1)]','-k','LineWidth',2);set(gca,'FontSize',12)gridon;boxon;xlim([-44])
Licensing
I, the copyright holder of this work, hereby publish it under the following license:
The person who associated a work with this deed has dedicated the work to the public domain by waiving all of their rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law. You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.
http://creativecommons.org/publicdomain/zero/1.0/deed.enCC0Creative Commons Zero, Public Domain Dedicationfalsefalse