Last active
April 15, 2017 21:01
-
-
Save rlee287/746e96c7b9e9dd5cfe2f1a40c7b6dc1a to your computer and use it in GitHub Desktop.
The effect of noise on numerical integration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from scipy import integrate | |
import matplotlib.pyplot as plt | |
# Testing data that can be replaced with file load-in | |
x=np.linspace(0,100,201) | |
accel=np.zeros_like(x) | |
accel[30:32]=1 | |
accel[50:52]=-1 | |
velocity=integrate.cumtrapz(accel,x,initial=0) | |
plt.plot(x,accel,label="Pulses") | |
plt.plot(x,velocity,label="Integrate") | |
plt.legend() | |
plt.show() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from scipy import integrate | |
import matplotlib.pyplot as plt | |
# Testing data that can be replaced with file load-in | |
x=np.linspace(0,100,201) | |
accel=np.zeros_like(x) | |
accel[30:32]=1 | |
accel[50:52]=-1 | |
ran=np.random.rand(201) | |
ran-=0.5 | |
ran*=0.04 | |
accel+=ran | |
velocity=integrate.cumtrapz(accel,x,initial=0) | |
plt.plot(x,accel,label="Pulses") | |
plt.plot(x,velocity,label="Integrate") | |
plt.legend() | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment