29 lines
1.0 KiB
Python
29 lines
1.0 KiB
Python
import numpy as np
|
|
import matplotlib.pyplot as plt
|
|
from plotstyle import *
|
|
|
|
# normal distribution:
|
|
x = np.arange(-3.0, 5.0, 0.01)
|
|
g = np.exp(-0.5*x*x)/np.sqrt(2.0*np.pi)
|
|
x1=0.0
|
|
x2=1.0
|
|
|
|
fig, ax = plt.subplots(figsize=cm_size(figure_width, 1.2*figure_height))
|
|
ax.set_xlabel('x')
|
|
ax.set_ylabel('Probability density p(x)')
|
|
ax.set_ylim(0.0, 0.46)
|
|
ax.set_yticks(np.arange(0.0, 0.45, 0.1))
|
|
ax.annotate('Gaussian',
|
|
xy=(-1.0, 0.28), xycoords='data',
|
|
xytext=(-2.5, 0.35), textcoords='data', ha='left',
|
|
arrowprops=dict(arrowstyle="->", relpos=(0.5,0.0),
|
|
connectionstyle="angle3,angleA=10,angleB=110"))
|
|
ax.annotate('$P(0<x<1) = \int_0^1 p(x) \, dx$',
|
|
xy=(0.5, 0.24), xycoords='data',
|
|
xytext=(1.2, 0.4), textcoords='data', ha='left',
|
|
arrowprops=dict(arrowstyle="->", relpos=(0.0,0.5),
|
|
connectionstyle="angle3,angleA=10,angleB=80"))
|
|
ax.fill_between(x[(x>x1)&(x<x2)], 0.0, g[(x>x1)&(x<x2)], **fsBs)
|
|
ax.plot(x,g, **lsA)
|
|
fig.savefig('pdfprobabilities.pdf')
|