def get_exog(N, num_nonconst_covariates, cor_length):
 uncorrelated_exog = sp.randn(N, num_nonconst_covariates)
 if (cor_length == 0):
  exog = uncorrelated_exog
 else:
  cov_matrix = sp.zeros((num_nonconst_covariates, num_nonconst_covariates))
  j = sp.arange(num_nonconst_covariates)
  for i in range(num_nonconst_covariates):
   cov_matrix[i, :] = sp.exp(((- sp.fabs((i - j))) / cor_length))
  chol = linalg.cholesky(cov_matrix)
  exog = sp.dot(uncorrelated_exog, chol)
 return exog

def get_exog ( N , num_nonconst_covariates , cor_length ) : uncorrelated_exog = sp . randn ( N , num_nonconst_covariates ) if ( cor_length == 0 ) : exog = uncorrelated_exog else : cov_matrix = sp . zeros ( ( num_nonconst_covariates , num_nonconst_covariates ) ) j = sp . arange ( num_nonconst_covariates ) for i in range ( num_nonconst_covariates ) : cov_matrix [ i , : ] = sp . exp ( ( ( - sp . fabs ( ( i - j ) ) ) / cor_length ) ) chol = linalg . cholesky ( cov_matrix ) exog = sp . dot ( uncorrelated_exog , chol ) return exog
returns an exog array with correlations determined by cor_length .