Skip to content

Instantly share code, notes, and snippets.

@ikamensh
Last active October 10, 2019 09:31
Show Gist options
  • Save ikamensh/e418afab990b49a0cf7e547cd4543628 to your computer and use it in GitHub Desktop.
Save ikamensh/e418afab990b49a0cf7e547cd4543628 to your computer and use it in GitHub Desktop.
Challenges of plotting
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