How do you sample data from a known distribution? Lets say I have a known probability distribution. It could be power-law distribution or a Gaussian distribution for example. If I know the necessary parameters of the distribution, then how do I explicitly sample data points from this known distribution? 
I realized that I have so far fitted data into probability distributions but I have never sampled data from other probability distributions other than the uniform distribution which is trivial to do. 
How do I explicitly code this e.g. in Matlab? Could I have an easy example?
 A: There is a number of methods for pseudo-random numbers generation (check other threads tagged as random-generation). One of the most simple and popular ones is inverse transform method. You could also use other algorithms as rejection sampling, slice sampling, or ziggurat algorithm (see also this recent thread). Luc Devroye (1986) wrote a whole book on this topic.
As about software, most statistical software includes functions for sampling for most common distributions. For example, in R you use r* functions: rnorm for normal distribution, rt for $t$-distribution, rpois for Poisson distribution etc. Google search suggests that Matlab also has such functions, e.g random, or normrnd.

Devroye, L. (1986). Non-Uniform Random Variate Generation. New York: Springer-Verlag.
A: For Gaussian distributions, you can just use the built-in randn function. It will give you a sample from the normal distribution. Then you just have to multiply it by the standard deviation and add the mean to get a sample from any Gaussian distribution.
For a general distribution, you can use inverse transform sampling. The idea is that you first sample from a uniform distribution, then use the cdf of your target distribution to find the value that matches the same quantile in your target distribution.
