from random import expovariate


def generate_random_times(lam = 1.0, a = 2.0, tmax = 1000.0):
    """
    Generate two Poisson processes with rates lam and a*lam
    Parameters
    ----------
    lam : float (optional)
        Rate of Poisson process 1.
    a : float (optional)
        Rate of second Poisson process will be a*lam.
    tmax : float (optional)
        Maximum time of the simulated processes.
    Returns
    -------
    times : dictionary of 2 lists of times
        Dictionary with the lists of times of events for each process.
    """
    times = {1:[], 2:[]}
    ids = times.keys()
    lam = 1.0
    l = [lam, a*lam]
    for idi in ids:
        lm = l[idi - 1]
        t = expovariate(lm)
        while t < tmax:
            times[idi].append(t)
            t += expovariate(lm)
    return times