def CorrelatedGenerator(rho):
 x = random.gauss(0, 1)
 (yield x)
 sigma = math.sqrt((1 - (rho ** 2)))
 while True:
  x = random.gauss((x * rho), sigma)
  (yield x)

def CorrelatedGenerator ( rho ) : x = random . gauss ( 0 , 1 ) ( yield x ) sigma = math . sqrt ( ( 1 - ( rho ** 2 ) ) ) while True : x = random . gauss ( ( x * rho ) , sigma ) ( yield x )
generates standard normal variates with serial correlation .