function y = poisson(n, lambda)
    // Generation of a Poisson's process
    // Usage:
    //       y = poisson(n, lambda)
    // where: 
    //       y:      Vector of instants (in s) of the eventos
    //               of a Poisson's process 
    //       n:      Number of events
    //       lambda: mean mumber of events per unit time (in 1/s)
    //        
    // Let u be a random variable with uniform distribution 
    // between 0 y 1. Then the variable
    //
    //       h = -log(1 - u) / lambda
    //
    // where lambda is the mean number of events per unit
    // time, is a random variable with exponential 
    // distribution, i.e.,
    // 
    //       P(h < h0) = 1 - exp(-lambda*h0)
    //
    // which in turn implies that the values of h have the 
    // same dietribution as the intervals between events of 
    // a Poisson's distribution. Poissons's distribution has
    // the following properties:
    //
    // a) The number of events in an interval [t0, t0 + t]  
    //    is a random variable X that depends only on t, and  
    //    not on the instant t0.
    // b) The number of eventos taking place at disjopint 
    //    time intervals are independent random variables.
    // c) The probability that in a short time intervalo 
    //    [t0, t0 + t] an event takes place tends to be 
    //    proporcional to t: p1(t) =  t + o(t), where o(t) 
    //    is an infinitesimom of higher orden than t when 
    //    t --> 0.
    // d) The probability that in a short time interval 
    //    [t0, t0 + t] two or more events take place is,
    //    of higher order, i.e., o(t).
    //
    // ----------------------
    // Author: Federico Miyara
    // Date:   2010-03-19
    //         2021-02-07

    y = cumsum(-log(1 - rand(1,n))/lambda);

endfunction
