An easy and simple explanation would be appreciated.
Here's how to do this in Matlab using TINV from that statistics toolbox:
%# choose the degree of freedom df = 4; %# note you can also choose an array of df's if necessary %# create a vector of 100,000 uniformly distributed random varibles uni = rand(100000,1); %# look up the corresponding t-values out = tinv(uni,df);
With a more recent version of Matlab, you can also simply use TRND to create the random numbers directly.
out = trnd(100000,df);
Here's the histogram of
EDIT Re:merged question
Matlab has no built-in function for drawing numbers from a Laplace distribution. However, there is the function LAPRND from the Matlab File Exchange that provides a well-written implementation.
Easy answer: Use R and get
n variables for a $t$-distribution with
df degrees of freedom by
rt(n, df). If you don't use R, maybe you can write what language you use, and others may be able to tell precisely what to do.
If you don't use R or another language with a built in random number generator for the $t$-distribution, but you have access to the quantile function, $Q$, for the $t$-distribution and you can generate a uniform random variable $U$ on $[0,1]$ then $Q(U)$ follows a $t$-distribution.
Else take a look at this brief section in the Wikipedia page.
By looking at the Wikipedia article, I've written a function to generate random variables from the Laplace dsistribution. Here it is:
function x = laplacernd(mu,b,sz) %LAPLACERND Generate Laplacian random variables % % x = LAPLACERND(mu,b,sz) generates random variables from a Laplace % distribution having parameters mu and b. sz stands for the size of the % returned random variables. See  for Laplace distribution. % %  http://en.wikipedia.org/wiki/Laplace_distribution % % by Ismail Ari, 2011 if nargin < 1 % Equal to exponential distribution scaled by 1/2 mu = 0; end if nargin < 2 b = 1; end if nargin < 3 sz = 1; end u = rand(sz) - 0.5; x = mu - b*sign(u) .* log(1-2*abs(u));
And here is a code snippet to use it
clc, clear mu = 30; b = 2; sz = [50000 1]; x = laplacernd(mu,b,sz); hist(x,100)
The best (fastest to run, not fastest to code;) free solution I have found in Matlab was to wrap R's MATHLIB_STANDALONE c library with a mex function. This gives you access to R's t-distribution PRNG. One advantage of this approach is that you also can use the same trick to get variates from a non-central t distribution.
The second best free solution was to use octave's implementation of trnd. Porting from octave turned out to be more work than wrapping c code for me.
For my tastes, using uniform generation via
rand and inverting via
tinv was much too slow. YMMV.
You can use the same approach that was described in response to your question about generating random numbers from a t-distribution. First generate uniformly distributed random numbers from (0,1) and then apply the inverse cumulative distribution function of the Laplace distribution, which is given in the Wikipedia article you linked to.