title: Matlab Uniform Distribution to Exponential Distribution
body: <p>So this is the question: </p>
  
  <p>Suppose we only have a random number generator, which has a U(0, 1) distribution. But we want to generate a sequence of random numbers with a non-uniform distribution (e.g., Exp(2)). Now, please first use the random number generator to generate 105 uniformly (U(0, 1)) distributed samples then transform those samples to data points, which should have a Exp(2) distribution finally plot those transformed samples by using the hist function.</p>
  
  <p>I am having trouble converting to exponential. I emailed my TA and he wasn't much help, but he did tell me I don't need the loop.</p>
  
  <p>Here's what I have:</p>
  
  <pre><code>distnames = {'Uniform', 'Exponential'};
  lower=0;
  upper=1;
  uds = makedist(distnames{1},'lower' ,lower, 'upper', upper);
  nums = random(uds, 1, 10); %using 10 randoms for testing, needs to be 10^5
  
  for k=1:length(nums)
      mu=2;
      uds = makedist(distnames{2},'mu' ,mu);
      points = pdf(uds);
  end
  
  %%hist(points)
  </code></pre>