Skip to content

Commit

Permalink
Fix rho calculation and complex number handling in arburg2 algorithm
Browse files Browse the repository at this point in the history
This commit addresses two key issues in the Burg algorithm implementation. First, it corrects the calculation of rho to maintain its initial value throughout the algorithm, ensuring it accurately represents the total power of the input signal. Second, it resolves a ComplexWarning by explicitly using the real part of complex calculations, aligning with the expected behavior of the algorithm for real-valued signals.
  • Loading branch information
cl445 committed Dec 23, 2023
1 parent 9afb2d7 commit fb86a3a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/spectrum/burg.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def _arburg2(X, order):

temp = 1.
E = np.zeros(order+1)
E[0] = rho
E[0] = rho.copy()

for m in range(0, order):
#print m
Expand All @@ -74,7 +74,7 @@ def _arburg2(X, order):
a = a + ref[m] * np.flipud(a).conjugate()

# Update the prediction error
E[m+1] = (1 - ref[m].conj().transpose()*ref[m]) * E[m]
E[m+1] = (1 - ref[m].conj().transpose()*ref[m]).real * E[m]
#print 'REF', ref, num, den
return a, E[-1], ref

Expand Down

0 comments on commit fb86a3a

Please sign in to comment.