Generating a Series of Alternating Exponential Processes Elegantly

62 Views Asked by At

Suppose I start with a time series:

time = pd.date_range('1/1/2011', periods=600, freq='5M')

I'd like now to generate a corresponding series, say 'on', so that the entries of 'on' will correspond to an exponential process that is True with mean 10, then False with mean 20, then True with mean 10, and so on. (Conceptually, this fits a person who wakes for 10 minutes approximately, then sleeps for 20.)

I.e., 'on' should be generated as the following pseudo-code:

while not reached 600:
    generate o0 ~ exponential(10), fill the next o0 entries of 'on' with 'True'
    generate o1 ~ exponential(20), fill the next o1 entries of 'on' with 'False'  

This is trivial to do with loops. Is there some nicer way to do it?

0

There are 0 best solutions below