mathdistops

Submodules

Package Contents

Functions

pnorm(q[, mean, std_dev, graph])

Calculates Cumulative Probability of the normal distribution at this quantile and plots corresponding PDF and CDF.

qnorm

qexp(p[, rate, graph])

Calculates the quantile corresponding to given cumulative probability in an exponential distribution and plots the corresponding distribution.

pexp(q[, rate, graph])

Calculates the cumulative probability of the exponential distribution at this quantile and plots corresponding PDF and CDF.

Attributes

__version__

mathdistops.__version__
mathdistops.pnorm(q, mean=0, std_dev=1, graph=True)[source]

Calculates Cumulative Probability of the normal distribution at this quantile and plots corresponding PDF and CDF.

Parameters:
  • q (float) – The quantile at which to evaluate the CDF.

  • mean (float) – The mean (average) of the normal distribution. Default is 0.

  • std_dev (float) – The standard deviation of the normal distribution. Default is 1.

  • graph (bool) – Whether to plot the PDF and CDF graph. Default is True.

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.

Return type:

pandas.DataFrame or tuple

Raises:
  • ValueError: – If ‘std_dev’ is zero or negative, as the standard deviation must be a positive number.

  • TypeError: – If any of the input parameters (‘q’, ‘mean’, ‘std_dev’) are not numerical.

Example

>>> pnorm(1, mean=0, std_dev=1, graph=False)
    Z-score    Cumulative probability
0   1.0        0.8413447460685429
mathdistops.qnorm(p, mean=0, std_dev=1, graph=True)[source]

Quantile (Inverse Cumulative Distribution Function) of the normal distribution.

Parameters:
  • p (float) – The probability for which to find the quantile.

  • mean (float, optional) – The mean (average) of the normal distribution. Default is 0.

  • std_dev (float, optional) – The standard deviation of the normal distribution. Default is 1.

  • graph (bool, optional) – Whether to plot the PDF and CDF graphs. Default is True.

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.

Return type:

pandas.DataFrame or tuple

Raises:
  • TypeError: – If any of the input parameters (‘p’, ‘mean’, ‘std_dev’) are not numerical.

  • ValueError: – If ‘p’ is not within the range [0, 1]. If ‘std_dev’ is zero or negative, as standard deviation must be positive.

Example

>>> qnorm(0.8413447460685429, mean=0, std_dev=1, graph=False)
    Quantile
0   1.0
mathdistops.qexp(p, rate=1, graph=True)[source]

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.

Parameters:
  • p (float, optional) – The cumulative probability for which to find the quantile. Must be between 0 and 1, inclusive of 1.

  • rate (float) – The rate parameter (lambda) of the exponential distribution. Must be a positive number. Default is 1

  • graph (bool, optional) – If True, generates and returns a plot of the exponential distribution with the quantile highlighted for the given cumulative probability. Default is True.

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.

Return type:

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.

Examples

>>> qexp(0.5, rate=1, graph=False)
    Probability     Quantile
0   0.5             0.6931471805599453
mathdistops.pexp(q, rate=1, graph=True)[source]

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.

Parameters:
  • q (float) – The quantile at which to evaluate the CDF.

  • rate (float) – The rate parameter (lambda) of the exponential distribution. Default is 1.

  • graph (bool) – Whether to plot the PDF and CDF graph. Default is True.

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.

Return type:

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.

  • TypeError: – If either ‘q’ or ‘rate’ is not a numerical value.

Examples

>>> pexp(0.5, rate=1, graph=False)
    Quantile    Cumulative probability
0   0.5         0.393469