def correlated_signal(coeff, n=1000):
    '\n    Create a correlated random signal of length `n` based on the correlation coefficient `coeff`\n          value[t] = coeff * value[t-1]  + (1-coeff) * random\n    '
    if ((coeff < 0) or (coeff > 1)):
        raise Exception('Correlation coefficient should be between 0 and 1')
    x = np.zeros(n)
    rvec = rand(n)
    x[0] = rvec[0]
    for m in np.arange(1, n):
        x[m] = ((coeff * x[(m - 1)]) + ((1 - coeff) * rvec[m]))
    x -= np.mean(x)
    return x
Create a correlated random signal of length `n` based on the correlation coefficient `coeff`
      value[t] = coeff * value[t-1]  + (1-coeff) * random
def correlated_signal(coeff, n=1000):
    '\n    Create a correlated random signal of length `n` based on the correlation coefficient `coeff`\n          value[t] = coeff * value[t-1]  + (1-coeff) * random\n    '
    if ((coeff < 0) or (coeff > 1)):
        raise Exception('Correlation coefficient should be between 0 and 1')
    x = np.zeros(n)
    rvec = rand(n)
    x[0] = rvec[0]
    for m in np.arange(1, n):
        x[m] = ((coeff * x[(m - 1)]) + ((1 - coeff) * rvec[m]))
    x -= np.mean(x)
    return x