graphics: Drawing Laplace
This commit is contained in:
parent
bc313505a3
commit
a3e29cb234
32
code/plots/laplace-adj-graph.py
Normal file
32
code/plots/laplace-adj-graph.py
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import numpy as np
|
||||||
|
from matplotlib import pyplot as plt
|
||||||
|
from scipy.stats import laplace
|
||||||
|
|
||||||
|
plt.rc('font', family='serif')
|
||||||
|
plt.rc('font', size=10)
|
||||||
|
plt.rc('text', usetex=True)
|
||||||
|
|
||||||
|
x = np.arange(0.0, 6.0, 0.01)
|
||||||
|
|
||||||
|
# Draw the first laplace distribution.
|
||||||
|
plt.plot(x,\
|
||||||
|
laplace.pdf(x, loc=2.0, scale=1.0),\
|
||||||
|
label=r'$\textrm{Laplace}(2, 1)$',\
|
||||||
|
color='#009874')
|
||||||
|
|
||||||
|
# # Draw the second laplace distribution.
|
||||||
|
# plt.plot(x,\
|
||||||
|
# laplace.pdf(x, loc=1.0, scale=1.0),\
|
||||||
|
# label=r'$\textrm{Laplace}(1, 1)$',\
|
||||||
|
# color='#e52e4e')
|
||||||
|
|
||||||
|
# Configure the plot.
|
||||||
|
plt.axis([0.0, 6.0, 0.0, 0.6]) # Set plot box.
|
||||||
|
plt.legend(loc='best', frameon=False) # Set plot legend.
|
||||||
|
plt.grid(axis='y', alpha=1.0) # Add grid on y axis.
|
||||||
|
plt.xlabel('Count') # Set x axis label.
|
||||||
|
plt.ylabel('Probability') # Set y axis label.
|
||||||
|
|
||||||
|
plt.show() # Show the plot in a new window.
|
28
code/plots/laplace-graph.py
Normal file
28
code/plots/laplace-graph.py
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#!/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()
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user