Communication theory in layman's language version of the Python code
The principle is easy to understand communication Aijun's impressive effort, to communicate people to their homes serial, here only for training notes python code used by
Chen's serial I start from the polynomial multiplication, step by step leads to convolution, Fourier series expansion, rotation vector, three-dimensional spectrum, IQ modulation, digital modulation and a series of communication theory knowledge
Serial 1: Starting from the polynomial multiplication
\[ (x+1)(x^2+2x+5)=x^3+3x^2+7x+5 \]
import sympy
x = sympy.Symbol('x')
sympy.expand((x+1)*(x*x+2*x+5))
This calculation summed up:
deconvolution: Usually polynomial x are arranged in descending, where the press in which are arranged in ascending a polynomial of x.
Pan: x will be arranged in ascending translation of a polynomial of each item to the right.
Multiplication: multiplying each vertically aligned items.
Sum: summing each result of the multiplication.Deconvolution, translation, multiplying, summing - this is the most commonly used communication theory concept of a " convolution " of the calculation process.
Serial 2: convolution expression
Converting the polynomial matrix form
\ [x + 1 -> [ 1,1] \\ x ^ 2 + 2x + 5 -> [1,2,5] \\ x ^ 3 + 3x ^ 2 + 7x + 5 = [1,1] * [1,2,5] = [1,3,7,5] \]
wherein the convolution (*) operation is as follows:
\ (C (n-) = a (n-) B * (n- ) = \ sum_ {k = 0
} ^ n {a (k) b (nk)}, n = 0 ~ (n1 + n2) \) where n1 is a (n) is the total number of coefficients, n2 is B ( n) the total number of coefficients
Python convolution calculation
import numpy as np
np.convolve([1,1],[1,2,5]) #上例,result:[1, 3, 7, 5]
# 杨辉三角,输入行数,输出对应行的值
def pascal_triangle(n):
if n == 0:
return 1
elif n == 1:
return [1,1]
else:
return np.convolve([1,1],pascal_triangle(n-1))
# test code
for i in range(0,7):
print(pascal_triangle(i))
# 杨辉三角,迭代器形式
def triangles():
nlist=[1]
while True:
yield nlist
nlist.append(0)
nlist = [nlist[i] + nlist[i-1] for i in range(len(nlist))]
# test code
tr = triangles()
for i in range(0,7):
print(next(tr))