Created
August 12, 2018 11:21
-
-
Save certifiedwaif/d9c7fd207b54a3fccae5f577c17f95d3 to your computer and use it in GitHub Desktop.
What, you expect me to do this by hand?!?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
matrix_str = """\\sigma^2_{\\text{intercept}} & & & & & | |
\\rho_{\\text{intercept} x} & \\sigma^2_x & \\ldots | |
\\rho_{\\text{intercept} x^2} & \\rho_{x x^2} & \\sigma^2_{x^2} & \\ldots | |
\\rho_{\\text{intercept} x^3} & \\rho_{x x^3} & \\rho_{x^2 x^3} & \\sigma^2_{x^3} & \\ldots | |
0 & \\rho_{x (x - \\kappa_1)^3_+} & \\rho_{x^2 (x-\\kappa_1)_+^3} & \\rho_{x^3 (x - \\kappa_1)_+^3} & \\sigma^2_{(x - \\kappa_1)_+^3} & \\ldots | |
0 & 0 & \\rho_{x^2 (x-\\kappa_2)_+^3} & \\rho_{x^3 (x-\\kappa_2)_+^3} & \\rho_{(x-\\kappa_1)_+^3 (x-\\kappa_2)_+^3} & \\sigma^2_{(x - \\kappa_2)_+^3} | |
0 & 0 & 0 & \\rho_{x^3 (x - \\kappa_3)_+^3} & \\rho_{(x - \\kappa_1)_+^3 (x - \\kappa_3)_+^3} & \\rho_{(x - \\kappa_2)_+^3 (x - \\kappa_3)_+^3} & \\sigma^2_{(x - \\kappa_3)_+^3} """ | |
lines = matrix_str.split("\n") | |
matrix = [line.split("&") for line in lines] | |
matrix = [[el.strip() for el in line] for line in matrix] | |
matrix_out = [["" for x in range(7)] for y in range(7)] | |
for i in range(7): | |
for j in range(i + 1): | |
matrix_out[i][j] = matrix[i][j] | |
matrix_out[j][i] = matrix[i][j] | |
for i in range(7): | |
for j in range(7): | |
print(matrix_out[i][j], end="") | |
if j < 6: | |
print("&", end="") | |
else: | |
print("\\\\") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment