.. _weibull_dose:

Weibull Dose
==========================

The examples given so far have shown the amount of drug absorbed with respect to time, rising from an initial value (typically zero) to the amount administered.

They can, alternatively, be viewed as the cumulative probability of 1 |nbsp| mg of drug having been absorbed at any given time, multiplied by the total amount (in mg) of drug administered. (Because a density function has unit area under the curve, the scaling ensures that the total dose administered is equal to *AMT*.) This formulation allows us to consider alternative dosing functions by using different probability distributions.

.. comment
    See also https://www.pharmpk.com/PK09/PK2009395.html

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

One choice that has been proposed [Piotrovskii1987]_ uses the `Weibull distribution <https://en.wikipedia.org/wiki/Weibull_distribution>`_ [Christensen1980]_ where the amount, :math:`S(t)`, absorbed at time :math:`t` following a dose of *AMT* at time :math:`t=t_0` is given by

.. math::

    S(t) = AMT \cdot \exp \left\{
        -\left(
            \frac{t-t_0}{\lambda}
        \right)^\kappa
    \right\}

such that

.. math::

    \frac{dS(t)}{dt} =
    \left \{
        \begin{array}{lr}
            \frac{\kappa}{\lambda}
            \left(
                \frac{t-t_0}{\lambda}
            \right)^{\kappa-1} \cdot
            AMT \cdot \exp \left\{
                -\left(
                    \frac{t-t_0}{\lambda}
                \right)^{\kappa}
            \right \},
            & \text{for } t \geq t_0 \\

            0,
            & \text{otherwise} \\
        \end{array}
    \right \}

where :math:`{\lambda}` (lambda) and :math:`{\kappa}` (kappa) are, respectively, scale and shape parameters of the Weibull distribution.

In other words, for :math:`t \geq t_0`

.. math::

    \frac{dS(t)}{dt} = 
        \frac{\kappa}{\lambda}
        \left(
            \frac{t-t_0}{\lambda}
        \right)^{\kappa-1} \cdot S(t)
        
which can be viewed as a rate absorption constant that varies over time, reflecting the possibility that a molecule of drug may be more likely to be absorbed the longer it is resident in the body (for example, due to passage of the drug into the intestine).

A shortcut for the Weibull dosing function is applied in |popy| using

.. code-block:: pyml

    @weibull{amt: c[AMT], lag: m[LAG], lambda: m[LAMBDA], kappa: m[KAPPA]}

in the equation for the appropriate compartment in the |derivatives| section of an input script.

The lag works in the same way as for a bolus dose, delaying the onset of the weibull dose. Again, this can be left out if we assume no lag:

.. code-block:: pyml

    DERIVATIVES: |
        d[CENTRAL] = @weibull{amt: c[AMT], lambda: m[LAMBDA], kappa: m[KAPPA]}

.. figure:: /case-studies/indiv_examples/dosing/weibull_tut/images/gen_sim_grph_outputs/allOBS_vs_TIME/comb_spag.*
    :name: fig_weibull_dose
    :align: center
    :width: 50%
    :alt: Cumulative amount following a Weibull dose with no elimination

    Cumulative amount following a Weibull dose with no elimination
