diff --git a/README.md b/README.md index a158d0d..0e0744e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ # modwtpy +Forked from main and rewritten loop to list compr. for speed by Aske Ejdrup, 2022. + modwt in python find the detail from the matlab Documentation: @@ -17,4 +19,4 @@ import pandas as pd gdpdata = pd.DataFrame.from_csv('GDPcomponents.csv') wt = modwt(gdpdata['govtexp'], 'db2', 5) wtmra = modwtmra(wt, 'db2') -``` \ No newline at end of file +``` diff --git a/modwt.py b/modwt.py index b978c76..128d256 100644 --- a/modwt.py +++ b/modwt.py @@ -32,11 +32,7 @@ def circular_convolve_mra(h_j_o, w_j): ''' calculate the mra D_j''' N = len(w_j) l = np.arange(N) - D_j = np.zeros(N) - for t in range(N): - index = np.mod(t + l, N) - w_j_p = np.array([w_j[ind] for ind in index]) - D_j[t] = (np.array(h_j_o) * w_j_p).sum() + D_j = [(h_j_o * w_j[np.mod(t + l, N)]).sum() for t in range(N)] return D_j