# Plotting uniform and Gaussian random variables

I want to create uniform and Gaussian (normal) random variables in MATLAB via rand and randn syntax. And I would like to plot the PDF and CDF of aforementioned random variables with two methods. The first one, determining Relative Frequency, the second one, Histogram.

Also, how can I prove that rand syntax corresponds to Uniform RV and randn syntax corresponds to Normal RV?

• Welcome to DSP.SE! What is your question? Can you read the manual entries on rand and randn ? Is that proof enough? In any event, your question seems either about programming in Matlab, or asking us to write a program for you. Please rephrase your question to ask about this you don't understand, rather than asking us to do the work for you. – Peter K. Oct 23 '15 at 20:13
• Thanks for your reaction!!! How can i plot CDF of a Uniform and Gaussian RVs in MATLAB? – Sahab Oct 24 '15 at 10:56
• For plotting PDF, i use below MATLAB code. Is it true or not? numsamples = 1e+6; / hist(rand(1,numsamples)) – Sahab Oct 24 '15 at 11:01
• YEAH, if you can just proof it,,,, how can i proof it?????? – Sahab Oct 24 '15 at 11:07

cumsum command of MATLAB can be used to plot CDF while as histogram command can be used to plot PDF of RVs. Check out the following links for detailed description:

http://de.mathworks.com/help/matlab/ref/cumsum.html?refresh=true

http://de.mathworks.com/help/matlab/ref/histogram.html

• What about "cdfplot" synatx that draws emricial CDF of a arbitrary RV? – Sahab Oct 24 '15 at 14:53
• Cdfplot requires statistics toolbox. Without the toolbox you can use cumsum function. – rmb Oct 25 '15 at 16:43