#!/usr/bin/env python # coding: utf-8 # In[42]: get_ipython().run_line_magic('matplotlib', 'inline') import numpy as np import matplotlib.pyplot as plt x=np.array([0.,0,0,2,4,6,4,2,0,0,0]) plt.stem(x) # In[43]: y=x*0 y[0]=1/3*(x[0]+x[1]+x[2]) y[1]=1/3*(x[1]+x[2]+x[3]) # In[44]: for ii in range(5): print(ii) # In[45]: for ii in range(len(x)-2): y[ii]=1/3.*(x[ii]+x[ii+1]+x[ii+2]) print(y[ii]) # In[14]: plt.stem(x,'r') plt.stem(y,'g') # In[ ]: