Last active
October 10, 2019 09:31
-
-
Save ikamensh/e418afab990b49a0cf7e547cd4543628 to your computer and use it in GitHub Desktop.
Challenges of plotting
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 matplotlib import pyplot as plt | |
def noisy_mapping( mapping ): | |
def _(x): | |
y = mapping(x) | |
y += np.random.normal(0, 2, size=y.size) | |
return y | |
return _ | |
funcs = {} | |
funcs['sin'] = noisy_mapping(np.sin) | |
funcs['log'] = noisy_mapping(np.log) | |
funcs['pow1.5'] = noisy_mapping(lambda x: x**(3/2)) | |
X = np.arange(0.1, 10, step=0.001) | |
for name, func in funcs.items(): | |
plt.plot(X, func(X)) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment