:py:mod:`mathdistops` ===================== .. py:module:: mathdistops Submodules ---------- .. toctree:: :titlesonly: :maxdepth: 1 pexp/index.rst pnorm/index.rst qexp/index.rst qnorm/index.rst Package Contents ---------------- Functions ~~~~~~~~~ .. autoapisummary:: mathdistops.pnorm mathdistops.qnorm mathdistops.qexp mathdistops.pexp Attributes ~~~~~~~~~~ .. autoapisummary:: mathdistops.__version__ .. py:data:: __version__ .. py:function:: pnorm(q, mean=0, std_dev=1, graph=True) Calculates Cumulative Probability of the normal distribution at this quantile and plots corresponding PDF and CDF. :param q: The quantile at which to evaluate the CDF. :type q: float :param mean: The mean (average) of the normal distribution. Default is 0. :type mean: float :param std_dev: The standard deviation of the normal distribution. Default is 1. :type std_dev: float :param graph: Whether to plot the PDF and CDF graph. Default is True. :type graph: bool :returns: **result** -- If `graph` is True (default), returns a tuple consisting a pandas DataFrame and a layered altair Chart consisting of two graphs, CDF and PDF. If `graph` is False, returns a pandas DataFrame. :rtype: pandas.DataFrame or tuple :raises ValueError:: If 'std_dev' is zero or negative, as the standard deviation must be a positive number. :raises TypeError:: If any of the input parameters ('q', 'mean', 'std_dev') are not numerical. .. rubric:: Example >>> pnorm(1, mean=0, std_dev=1, graph=False) Z-score Cumulative probability 0 1.0 0.8413447460685429 .. py:function:: qnorm(p, mean=0, std_dev=1, graph=True) Quantile (Inverse Cumulative Distribution Function) of the normal distribution. :param p: The probability for which to find the quantile. :type p: float :param mean: The mean (average) of the normal distribution. Default is 0. :type mean: float, optional :param std_dev: The standard deviation of the normal distribution. Default is 1. :type std_dev: float, optional :param graph: Whether to plot the PDF and CDF graphs. Default is True. :type graph: bool, optional :returns: **result** -- If `graph` is True (default), returns a tuple consisting a pandas DataFrame and a layered altair Chart consisting of two graphs, CDF and PDF. If `graph` is False, returns a pandas DataFrame. :rtype: pandas.DataFrame or tuple :raises TypeError:: If any of the input parameters ('p', 'mean', 'std_dev') are not numerical. :raises ValueError:: If 'p' is not within the range [0, 1]. If 'std_dev' is zero or negative, as standard deviation must be positive. .. rubric:: Example >>> qnorm(0.8413447460685429, mean=0, std_dev=1, graph=False) Quantile 0 1.0 .. py:function:: qexp(p, rate=1, graph=True) Calculates the quantile corresponding to given cumulative probability in an exponential distribution and plots the corresponding distribution. This function computes the quantile corresponding to a specified cumulative probability `p` for an exponential distribution characterized by a given rate parameter `lambda`. Optionally, it can also generate and return a visualization of the distribution. :param p: The cumulative probability for which to find the quantile. Must be between 0 and 1, inclusive of 1. :type p: float, optional :param rate: The rate parameter (`lambda`) of the exponential distribution. Must be a positive number. Default is 1 :type rate: float :param graph: If True, generates and returns a plot of the exponential distribution with the quantile highlighted for the given cumulative probability. Default is True. :type graph: bool, optional :returns: **result** -- If `graph` is True (default), returns a tuple consisting of a pandas DataFrame giving you the cumulative probability and the quantile as well as a layered altair Chart consisting of two graphs, CDF and PDF. If `graph` is False, returns a pandas DataFrame. :rtype: pandas.DataFrame or tuple :raises ValueError:: If the cumulative probability 'p' is not between 0 and 1, exclusive of 1. If the rate parameter 'rate' is not a positive number. .. rubric:: Examples >>> qexp(0.5, rate=1, graph=False) Probability Quantile 0 0.5 0.6931471805599453 .. py:function:: pexp(q, rate=1, graph=True) Calculates the cumulative probability of the exponential distribution at this quantile and plots corresponding PDF and CDF. This function computes the cumulative probability at a specified quantile `q` for an exponential distribution with a given rate parameter `lambda`. Optionally, it can generate and return a visualization corresponding PDF and CDF. :param q: The quantile at which to evaluate the CDF. :type q: float :param rate: The rate parameter (lambda) of the exponential distribution. Default is 1. :type rate: float :param graph: Whether to plot the PDF and CDF graph. Default is True. :type graph: bool :returns: **result** -- If `graph` is True (default), returns a tuple consisting of a pandas DataFrame and a layered altair Chart consisting of two graphs, CDF and PDF. If `graph` is False, returns a pandas DataFrame. :rtype: pandas.DataFrame or tuple :raises ValueError:: If 'q' is None, indicating that the quantile parameter is missing. If 'rate' is zero or negative, indicating an invalid rate parameter. :raises TypeError:: If either 'q' or 'rate' is not a numerical value. .. rubric:: Examples >>> pexp(0.5, rate=1, graph=False) Quantile Cumulative probability 0 0.5 0.393469