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?

  • 1
    $\begingroup$ 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. $\endgroup$ – Peter K. Oct 23 '15 at 20:13
  • $\begingroup$ Thanks for your reaction!!! How can i plot CDF of a Uniform and Gaussian RVs in MATLAB? $\endgroup$ – Sahab Oct 24 '15 at 10:56
  • $\begingroup$ For plotting PDF, i use below MATLAB code. Is it true or not? numsamples = 1e+6; / hist(rand(1,numsamples)) $\endgroup$ – Sahab Oct 24 '15 at 11:01
  • $\begingroup$ YEAH, if you can just proof it,,,, how can i proof it?????? $\endgroup$ – 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:



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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.