show/hide this revision's text 2 added 49 characters in body

Given a covariance matrix, how can I construct a vector of expressions of randomly distributed variables whose covariance matrix is equal to the given one?

EDIT: All variables are normally distributed.

I have an algorithm that gets the covariances correct, but not the variances on the diagonal:

a = [0]*len(r)
for x, row in enumerate(cov_matrix(r)):
    for y, item in enumerate(row):
        if x > y: continue
        v = noise(math.sqrt(abs(item)))
        a[x] += v
        if item > 0:
            a[y] += v
        else:
            a[y] -= v

I feel like this should be simple ...

show/hide this revision's text 1

Computing equivalent vector of random variables from covarience matrix

Given a covariance matrix, how can I construct a vector of expressions of randomly distributed variables whose covariance matrix is equal to the given one?

I have an algorithm that gets the covariances correct, but not the variances on the diagonal:

a = [0]*len(r)
for x, row in enumerate(cov_matrix(r)):
    for y, item in enumerate(row):
        if x > y: continue
        v = noise(math.sqrt(abs(item)))
        a[x] += v
        if item > 0:
            a[y] += v
        else:
            a[y] -= v

I feel like this should be simple ...