-
Notifications
You must be signed in to change notification settings - Fork 194
Closed
Description
I found 2 bugs from awgn(), using complex input signals.
https://github.com/veeresht/CommPy/blob/master/commpy/channels.py#L97
I think 'is' should'nt be used for comparing dtype, instead of '=='.
For example...
>>> a
array([ 0.+1.j, 2.+0.j, 3.+0.j])
>>> a.dtype
dtype('complex128')
>>> a.dtype is complex
False
>>> a.dtype == complex
True
>>> a.dtype is np.dtype('complex128')
True
In python reference , 'x is y is true if and only if x and y are the same object.'
so You want to use 'is', compare with np.dtype('complex128').
https://github.com/veeresht/CommPy/blob/master/commpy/channels.py#L93
The Average energy of input signals is calculated from this equation.
avg_energy = sum(input_signal * input_signal)/len(input_signal)
But in the case input_signal is complex, you must calculate signal's absolute value before you square it.
avg_energy = sum(abs(input_signal) * abs(input_signal))/len(input_signal)
Metadata
Metadata
Assignees
Labels
No labels