def covariance_matrix(nums_with_uncert):
ufuncs = list(map(to_uncertain_func, nums_with_uncert))<EOL>cov_matrix = []<EOL>for (i1, expr1) in enumerate(ufuncs):<EOL><INDENT>coefs_expr1 = []<EOL>mean1 = expr1.mean<EOL>for (i2, expr2) in enumerate(ufuncs[: i1 + <NUM_LIT:1>]):<EOL><INDENT>mean2 = expr2.mean<EOL>coef = np.mean((expr1._mcpts - mean1) * (expr2._mcpts - mean2))<EOL>coefs_expr1.append(coef)<EOL><DEDENT>cov_matrix.append(coefs_expr1)<EOL><DEDENT>for (i, covariance_coefs) in enumerate(cov_matrix):<EOL><INDENT>covariance_coefs.extend(cov_matrix[j][i] for j in range(i + <NUM_LIT:1>, len(cov_matrix)))<EOL><DEDENT>return cov_matrix<EOL>
Calculate the covariance matrix of uncertain variables, oriented by the
order of the inputs

Parameters
----------
nums_with_uncert : array-like
    A list of variables that have an associated uncertainty

Returns
-------
cov_matrix : 2d-array-like
    A nested list containing covariance values

Example
-------

    >>> x = N(1, 0.1)
    >>> y = N(10, 0.1)
    >>> z = x + 2*y
    >>> covariance_matrix([x,y,z])
    [[  9.99694861e-03   2.54000840e-05   1.00477488e-02]
     [  2.54000840e-05   9.99823207e-03   2.00218642e-02]
     [  1.00477488e-02   2.00218642e-02   5.00914772e-02]]