In [12]:
from sympy import init_session
init_session()
a , mu, k, t = symbols('a, mu, k, t')


IPython console for SymPy 0.7.6 (Python 2.7.6-64-bit) (ground types: python)

These commands were executed:
>>> from __future__ import division
>>> from sympy import *
>>> x, y, z, t = symbols('x y z t')
>>> k, m, n = symbols('k m n', integer=True)
>>> f, g, h = symbols('f g h', cls=Function)
>>> init_printing()

Documentation can be found at http://www.sympy.org

Given is a PDF of a Branching Erlang (or Coxian) Distribution.


In [13]:
pdf = a * mu * exp(-mu*t)+ (((1-a)*(mu**k))/(factorial(k-1))) * (t**(k-1))*exp(-mu*t)
pdf


Out[13]:
$$a \mu e^{- \mu t} + \frac{\mu^{k} t^{k - 1}}{\left(k - 1\right)!} \left(- a + 1\right) e^{- \mu t}$$

In [14]:
cdf = integrate(pdf, t)
cdf


Out[14]:
$$a \mu \begin{cases} t & \text{for}\: \mu = 0 \\- \frac{1}{\mu} e^{- \mu t} & \text{otherwise} \end{cases} + \frac{k \left(- a + 1\right) \Gamma{\left(k \right)} \gamma\left(k, \mu t\right)}{\left(k - 1\right)! \Gamma{\left(k + 1 \right)}}$$

In [16]:
eq = diff(cdf,t) - pdf
simplify(eq)


Out[16]:
$$a \mu \begin{cases} 1 & \text{for}\: \mu = 0 \\e^{- \mu t} & \text{otherwise} \end{cases} - a \mu e^{- \mu t} - \frac{k \mu \left(\mu t\right)^{k - 1} \left(a - 1\right) e^{- \mu t} \Gamma{\left(k \right)}}{\left(k - 1\right)! \Gamma{\left(k + 1 \right)}} + \frac{\mu^{k} t^{k - 1}}{\left(k - 1\right)!} \left(a - 1\right) e^{- \mu t}$$

In [ ]: