Skip to content

Commit 6651bd0

Browse files
committed
Added plot example to docstring
1 parent 9bd165d commit 6651bd0

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

ompy/dist/fermi_dirac.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,27 @@ class FermiDirac(PositiveContinuous):
2424
2525
.. plot::
2626
27+
import matplotlib.pyplot as plt
28+
import numpy as np
29+
30+
x = np.linspace(0, 5., 1000)
31+
lam = [1.0, 10., 25.]
32+
mu = [0.5, 1.0, 2.0]
33+
34+
def pdf(x, lam, mu):
35+
return (lam/np.log(1 + np.exp(lam*mu))*(1/(np.exp(lam*(x-mu)) + 1))
36+
37+
for l in lam:
38+
for m in mu:
39+
pdf = pdf(x, l, m)
40+
plt.plot(x, pdf, label=f"$\lambda = {l}$, $\mu = {m}$")
41+
plt.xlabel("x", fontsize=12)
42+
plt.ylabel("f(x)", fontsize=12)
43+
plt.legend(loc=1)
44+
plt.show()
2745
2846
======== ============================
2947
Support :math:`x \in [0, \infty)`
30-
Mean
31-
Variance
3248
======== ============================
3349
3450
@@ -38,6 +54,14 @@ class FermiDirac(PositiveContinuous):
3854
Rate of decay at mu (lam > 0)
3955
mu: float
4056
Decay position
57+
58+
Examples
59+
--------
60+
.. code-block:: python
61+
62+
with pm.Model():
63+
x = ompy.FermiDirac('x', lam=10.0, mu=1.2)
64+
4165
"""
4266

4367
def __init__(self, lam, mu, *args, **kwargs):

0 commit comments

Comments
 (0)