Exponential-distributed Random Generator

De Augusto Baffa Wiki
Revisão de 09h56min de 30 de dezembro de 2020 por Abaffa (discussão | contribs) (Criou página com 'For generating an Exponential distribution from a Uniform distribution, we can use a powerful technique called “[https://en.wikipedia.org/wiki/Inverse_transform_sampling Inv...')
(dif) ← Edição anterior | Revisão atual (dif) | Versão posterior → (dif)
Ir para navegação Ir para pesquisar
Outros idiomas:
English • ‎português do Brasil

It is the continuous probability distribution of the time between events in a Poisson point process, i.e., a process in which events occur continuously and independently at a constant average rate.

For generating an Exponential distribution from a Uniform distribution, we can use a powerful technique called “Inverse Transform Method”. We don’t need to dwell on the theoretical details here, but ultimately this method links the two types of distributions through a simple mathematical transformation.

[math]Exp(i; \lambda) = -\frac{1}{\lambda}.ln(1 - U_i)[/math]

Sample Python Code

1 million attempts sample
def pseudo_exp(lamb, size=1):
    """
    Generates exponential distribution from uniform generator
    """
    # Sets seed based on the decimal portion of the current system clock
    t = time.perf_counter()
    seed = int(10**9*float(str(t-int(t))[0:]))
    
    U = pseudo_uniform(seed=seed, size=size)
    X = -(1/lamb)*(np.log(1-U))
    
    return X