title: Generating random numbers from the Laplace distribution
body: <p>I have been trying to generate random numbers from the double exponential(Laplace) distribution. I am at a point I can write the code anymore. Any help would be appreciated. The code below is what I have written.</p>
  
  <pre><code>rlaplace = function(u,a,b){
      u = c(runif(ns))
      for(i in 1:ns){
          if(u[i] &lt;= 0.5){
              X = a+b*log(2*u)
          } else{
              X = a-b*log(2*(1-u))
          }
      }
      X
  }
  z1 = rlaplace(u,a,b)
  </code></pre>