Issue
I've just discovered that function?
, like len?
will bring up documentation for that function in ipython.
One library has .. math::
blocks and .. plot::
in its docs.
The former seems to need to be passed to a latex engine and the latter to a python interpreter to plot a graph which is embedded in the docs. Sadly, in my jupyter notebooks client, I just get the code for these.
Is there any way to have this code be executed by both latex and python so that I may get the intended output?
NB: A sample output
pm.Exponential?
The pdf of this distribution is
.. math::
f(x \mid \lambda) = \lambda \exp\left\{ -\lambda x \right\}
.. plot::
import matplotlib.pyplot as plt
import numpy as np
import scipy.stats as st
plt.style.use('seaborn-darkgrid')
x = np.linspace(0, 3, 100)
for lam in [0.5, 1., 2.]:
pdf = st.expon.pdf(x, scale=1.0/lam)
plt.plot(x, pdf, label=r'$\lambda$ = {}'.format(lam))
plt.xlabel('x', fontsize=12)
plt.ylabel('f(x)', fontsize=12)
plt.legend(loc=1)
plt.show()
======== ============================
Support :math:`x \in [0, \infty)`
Mean :math:`\dfrac{1}{\lambda}`
Variance :math:`\dfrac{1}{\lambda^2}`
======== ============================
Parameters
----------
lam: float
Rate or inverse scale (lam > 0)
File: ~/.local/lib/python3.9/site-packages/pymc3/distributions/continuous.py
Type: type
Subclasses:
Solution
nbdev + fastbook gives me what I want.
The following snippet gives the intended result.
!pip install torch nbdev fastbook
import fastbook
fastbook.setup_book()
Answered By - Edward
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.