Adding some sciency code
My editor keeps saying “sciency” isn’t a word. A wise man once said, “Science isn’t about why. It’s about why not!?” I’m going to keep using it and if you’re actually reading this, it means I got away with it.
We’ve set up the IDE, and installed our required packages. Let’s open up main.py
and add some code so we can see PyCharm strut its stuff! In main.py
, add this code:
import numpy as np import matplotlib.pyplot as plt
These first two imports just bring in numpy
and matplotlib
with aliases. It turns out scientists hate typing more than normal developers:
N = 100 x = np.random.normal(0, 1, N) y = np.random.normal(2, 3, N) #%% plot data in histograms plt.hist(x, alpha=0.5, label='x') plt.hist(y, alpha=0.5, label='y') plt.legend(loc='upper right') plt.show()
Using NumPy, we are simply creating two sample 100-element datasets from normal distributions...