Module DigiCommPy.scripts.chapter_5.lms_test
Script: DigiCommPy.chapter_5.lms_test.py Verify LMS filter update equations (adaptive filter design) System identification using LMS algorithm
@author: Mathuranathan Viswanathan Created on Sep 4, 2019
Expand source code
"""
Script: DigiCommPy.chapter_5.lms_test.py
Verify LMS filter update equations (adaptive filter design)
System identification using LMS algorithm
@author: Mathuranathan Viswanathan
Created on Sep 4, 2019
"""
import numpy as np
from numpy.random import randn
from numpy import convolve
N = 5 # length of the desired filter
mu=0.1 # step size for LMS algorithm
r=randn(10000) # random input sequence of length 10000
h=randn(N)+1j*randn(N) # random complex system
a=convolve(h,r) # reference signal
from equalizers import LMSEQ
lms_eq = LMSEQ(N) #initialize the LMS filter object
lms_eq.design(mu,r,a) # design using input and reference sequences
print('System impulse response (h): {}'.format(h))
print('LMS adapted filter (w): {}'.format(lms_eq.w))
Functions
def randn(...)
-
randn(d0, d1, …, dn)
Return a sample (or samples) from the "standard normal" distribution.
If positive, int_like or int-convertible arguments are provided,
RandomState.randn()
generates an array of shape(d0, d1, ..., dn)
, filled with random floats sampled from a univariate "normal" (Gaussian) distribution of mean 0 and variance 1 (if any of the :math:d_i
are floats, they are first converted to integers by truncation). A single float randomly sampled from the distribution is returned if no argument is provided.This is a convenience function. If you want an interface that takes a tuple as the first argument, use
numpy.random.standard_normal
instead.Parameters
d0, d1, …, dn : int, optional The dimensions of the returned array, should be all positive. If no argument is given a single Python float is returned.
Returns
Z
:ndarray
orfloat
- A
(d0, d1, ..., dn)
-shaped array of floating-point samples from the standard normal distribution, or a single such float if no parameters were supplied.
See Also
standard_normal
- Similar, but takes a tuple as its argument.
Notes
For random samples from :math:
N(\mu, \sigma^2)
, use:sigma * np.random.randn(...) + mu
Examples
>>> np.random.randn() 2.1923875335537315 #random
Two-by-four array of samples from N(3, 6.25):
>>> 2.5 * np.random.randn(2, 4) + 3 array([[-4.49401501, 4.00950034, -1.81814867, 7.29718677], #random [ 0.39924804, 4.68456316, 4.99394529, 4.84057254]]) #random