![](/profiles/wavemetrics/themes/wavemetrics/logo.png)
Cumulative Distribution Function (CDF)
![](/sites/default/files/styles/thumbnail/public/default_images/Artboard%201_1.png?itok=jeHOCIXy)
bech
The code below will estimate the cumulative distribution function, P(X≥x) from a wave of observations. There is an option to plot the complementary cumulative distribution function, P(X≤x), as well. Note that an alternative way to calculate this would be to create an ordinary histogram and integrate. The version presented here is without binning. The two advantages are that (1) you don't have to worry about optimal bin size and (2) you do not lose any information.
The attached example program shows typical results.
Function MakeCDF(w,sortflag) // creates empirical cumulative distribution function wave w; variable sortflag variable n=numpnts(w) string wroot=NameofWave(w),cdfname=wroot+"_cdf" duplicate /o w $cdfname wave cdfwave=$cdfname if (sortflag == 1) Sort /R cdfwave cdfwave // largest values first (for complementary CDF) else Sort cdfwave cdfwave // smallest values first (for CDF); default case endif SetScale x 0,1,"", cdfwave // fraction of x values End
![Normal CDF and Power-law cCDF](/sites/default/files/styles/content_body/public/images-imported/MakeCDFlayout.preview.jpg?itok=8X-lQd06)
![](/sites/default/files/forum.png)
Forum
![](/sites/default/files/support.png)
Support
![](/sites/default/files/gallery.png)
Gallery
Igor Pro 9
Learn More
Igor XOP Toolkit
Learn More
Igor NIDAQ Tools MX
Learn More