the-last-thing/code/plots/laplace-graph.py

29 lines
634 B
Python

#!/usr/bin/env python3
import sys
sys.path.insert(1, 'code/lib')
import lmdk_lib
import numpy as np
from matplotlib import pyplot as plt
from scipy.stats import laplace
# Initialize plot
lmdk_lib.plot_init()
# The x axis
x = np.arange(0.0, 6.0, 0.01)
plt.xlabel('Count')
# Set y axis label
plt.ylabel('Likelihood')
# Draw the first laplace distribution
plt.plot(x,
laplace.pdf(x, loc=2.0, scale=1.0),
label='Laplace(2, 1)',
linewidth=lmdk_lib.line_width)
# Configure the plot
plt.axis([0.0, 6.0, 0.0, 0.6]) # Set plot box.
# Plot legend
lmdk_lib.plot_legend()
# Show the plot in a new window
plt.show()