.. _gamma_dose:

Gamma Dose
==========================

This occurs when the release of the drug into a specific compartment follows a Gamma curve. See:-

https://en.wikipedia.org/wiki/Gamma_distribution

.. note:: 
    
    See the :ref:`sum_link_gamma_dosing_tut` for :ref:`tut_script` used to generate results in this section.

The mathematical expression for an Gamma dose starting at time :math:`t_S` with Weibull parameters :math:`\lambda` and :math:`\kappa` and total dose amount :math:`\text{AMT}` in compartment |central| is:-

.. math:: 

    \text{d[CENTRAL]} = \text{d[CENTRAL]} + \text{R(t)}

where:-

.. math::

    R(t)= 
    \Biggl \lbrace
    {
        \frac{ \beta^\alpha (t-t_S)^{\alpha-1} e^{-\beta (t-t_S)}}{\Gamma(\alpha)} ,\text{ if } { t \geq t_S }
        \atop
        0.0, \text{ otherwise }
    }

Where R(t) is the rate of drug absorption at time (t) and :math:`\lambda` and :math:`\kappa` are parameters of the Gamma. R(t) is the Gamma density function scaled by the |amt| parameter. Since a density function has unit area under the curve, the |amt| scaling ensures that the total dose administered is equal to |amt|.

This can be implemented in PoPy using:

.. code-block:: pyml

    @gamma{amt: c[AMT], lag: m[LAG], alpha: m[ALPHA], beta: m[BETA]}

in the equation for the appropriate compartment in the |derivatives| section of a :ref:`fit_script` or ref:`tut_script`. See :ref:`@gamma`.

Here the parameters map to the Gamma equation as follows:-

+---------------+------------------------+
| Parameter     | Symbol                 |
+===============+========================+
| alpha         | :math:`\alpha`         |
+---------------+------------------------+
| beta          | :math:`\beta`          |
+---------------+------------------------+

The lag is coded in the same way as for a bolus dose. A lag time merely delays the start time of the gamma dose.

An example of a gamma dose added to a one compartment model with no lag time is:

.. code-block:: pyml

    DERIVATIVES: |
        d[CENTRAL] = @gamma{amt: c[AMT], alpha: m[ALPHA], beta: m[BETA]} - m[KE]*s[CENTRAL]

.. figure:: /case-studies/indiv_examples/dosing/gamma_tut/images/gen_sim_grph_outputs/indOBS_vs_TIME/000001.*
    :name: fig_gamma_dose
    :align: center
    :width: 50%
    :alt: Cumulative amount following a Gamma dose with no elimination
    
    Cumulative amount following a Gamma dose with no elimination
