Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to smooth a function in python

x = np.linspace(0,2*np.pi,100)
y = np.sin(x) + np.random.random(100) * 0.8

def smooth(y, box_pts):
    box = np.ones(box_pts)/box_pts
    y_smooth = np.convolve(y, box, mode='same')
    return y_smooth

plot(x, y,'o')
plot(x, smooth(y,3), 'r-', lw=2)
plot(x, smooth(y,19), 'g-', lw=2)
Comment

PREVIOUS NEXT
Code Example
Python :: find how many of each columns value pd 
Python :: if list item is found in string get that item python 
Python :: python folder exists 
Python :: python pd.DataFrame.from_records remove header 
Python :: extract url from page python 
Python :: python code to remove file extension 
Python :: django redirect to external url 
Python :: ipynb to py online 
Python :: find the first occurrence of item in a list in python 
Python :: jupyter nbconvert 
Python :: django sort descending 
Python :: python print combinations of string 
Python :: what is join use for in python 
Python :: python list comprehension if else 
Python :: pip install django 
Python :: how to restart program in python 
Python :: python generate id 
Python :: circular array python 
Python :: how to add three conditions in np.where in pandas dataframe 
Python :: python get directory of current script file 
Python :: pathlib path exists 
Python :: upload py file using flask 
Python :: How to get the value of an Entry widget in Tkinter? 
Python :: pip is not a batch command but python is installed 
Python :: pygame caption 
Python :: beautifulsoup remove element 
Python :: django urlpattern 
Python :: dictionary to a dataframe pandas arrays must all be same length 
Python :: join pandas dataframe by column 
Python :: fastest clicker python 
ADD CONTENT
Topic
Content
Source link
Name
2+1 =