I have the following function which transforms list of numbers:
import numpy as np
from math import *
def walsh_transform(x):
if len(x) > 3:
n = len(x)
m = trunc(log(n, 2))
x = x[0:2 ** m]
h2 = [[1, 1], [1, -1]]
for i in range(m - 1):
if i == 0:
h = np.kron(h2, h2)
else:
h = np.kron(h, h2)
return np.dot(h, x) / 2. ** m
arr = [1.0, 1.0, 1.0, 2.0, 0.0, 0.0, 0.0, 0.0]
print(walsh_transform(arr))
It returns output [ 0.625 -0.125 -0.125 0.125 0.625 -0.125 -0.125 0.125]
How can I make it return output [0.625, -0.125, -0.125, 0.125, 0.625, -0.125, -0.125, 0.125] ? I.e. comma-separated values?