Package: mathdistops
mathdistopsMathdistops is a statistical package crafted to facilitate in-depth analysis and visualization of normal and exponential distributions, pivotal for a wide array of statistical modeling and data analysis tasks. It features a core set of functions (pnorm, qnorm, pexp, and qexp) capable of calculating cumulative probabilities and quantiles, while simultaneously generating plots of both the probability density function (PDF) and the cumulative distribution function (CDF) for each distribution.
Thus, this package stands out as an indispensable tool for statisticians, data scientists, and researchers seeking to derive meaningful insights from their data.ContributorsOur team listed in alphabetical order:Katherine ChenKun YaOak ChongSandra GrossFunctionsDescriptionpexp(q, rate=1, graph=True): Represents the Cumulative Distribution Function (CDF) of the exponential distribution characterized by a given parameterrate. The function calculates the cumulative probability for a given quantileqand plots the corresponding probability distribution (PDF) and the CDF.qexp(p, rate=1, graph=True): Quantile Function of an exponential distribution, characterized by a given rate parameterrate. The function calculates the quantile corresponding to given cumulative probabilitypin an exponential distribution. Optionally, it can also generate and return a visualization of the PDF and the CDF.pnorm(q, mean = 0, std_dev =1, graph = True): Cumulative Distribution Function of the normal distribution with specified mean and standard deviation. It will return the cumulative probability up to the given valueq. Optionally, it can generate and return a visualization of the distributions, the PDF and the CDF.qnorm(p, mean=0, std_dev=1, graph=True): Calculates the quantile (Inverse Cumulative Distribution Function) corresponding to a specified cumulative probabilitypof the normal distribution with specified mean and standard deviation. The function can additionally create and provide a graphical representation of the PDF and the CDF.A detailed documentation of the functions can be foundhere.DocumentationA detailed guide and tutorial for using these functions can be found on ReadTheDocs. For specific vignettes on the norm functions, please visit:https://mathdistops.readthedocs.io/en/latest/example_norm.html. Additionally, for comprehensive examples on the usage of qexp and pexp, refer to:https://mathdistops.readthedocs.io/en/latest/example_exp.html.InstallationFor UsersIn order to install the package you can run the following command from the terminal:pipinstallmathdistopsFor DevelopersThis package usesPoetryfor dependency management and packaging. To install and use this package, please follow these steps:Tocreate a new virtual environmentin Conda with Python, use the following commands in the terminal:condacreate--namemathdistopspython=3.9.0-yActivate the installed environmentvia:condaactivatemathdistopsPleaseinstalland set uppoetry:condainstallpoetryInstall the Package with Poetry: Use Poetry to install the package and its dependencies.poetryinstallNow you are ready to use the mathdistops package!UsageUsing this packageTo use this package, you can import and call its functions in your Python scripts. Here's an example:# Run this on jupyter notebook to import pnorm and qnorm functionfrommathdistopsimportpnorm,qnorm# Using pnorm to get the cumulative probability and plot for a normal distributiondf_pnorm,fig_pnorm=pnorm(1,mean=0,std_dev=1)print(df_pnorm)fig_pnormThe following image displays a sample usage in a Jupyter Notebook:Similar topnormfor the normal distribution,pexpoffers functionality for the exponential distribution. Here's how you can usepexpin a Jupyter Notebook:# Run this on jupyter notebook to import pexp and qexp functionfrommathdistopsimportpexp,qexp# Using pexp to get the cumulative probability and plot for an exponential distributiondf_pexp,fig_pexp=pexp(1,rate=1)print(df_pexp)fig_pexpBelow is an illustration of its usage in a Jupyter Notebook:Regardingqnormandqexp, these functions operate similarly, generating a DataFrame that summarizes the data and also producing plots for thePDFandCDF, with the calculated results indicated on the graphs. However, unlike their counterparts, they accept quantiles as inputs instead of probabilities.Running unit testsTo run unit tests for this package, addpytestto the environment file, which was created during the installation process via:condainstallpytestExecute the following in the project root directory:poetryrunpytestTo get a the code coverage reporting, run this command:poetryrunpytest--cov=mathdistops
poetryrunpytest--cov-branch--cov=mathdistopsPython Ecosystem IntegrationWhile python has relevant functions for normal and exponential distribution in the scipy.stats package, this package offer an in-built additional functionality of returning the plot to help with visualization and understanding the problem.Related Packages:scipy.stats.normis an official scipy package to represent a normal continuous random variable.scipy.stats.exponis an official scipy package to represent an exponential continuous random variable.However, these functions do not inherently produce visual outputs, requiring additional steps with a plotting library like Matplotlib for visualization. This stresses the unique selling point of themathdistops, which is its ability to encapsulate both the computational and visual aspects of statistical analysis into cohesive functions tailored for normal and exponential distributions.DependenciesThis package necessitates a Python version of 3 or higher. Additional required packages can be found in theenvironment fileof this repository.ContributingInterested in contributing? Check out the contributing guidelines. Please note that this project is released with a Code of Conduct. By contributing to this project, you agree to abide by its terms. Please check ourcontributing fileCode of ConductWelcome to our project! We appreciate your interest in contributing. Please follow ourcode of conductLicensemathdistopswas created by Katherine Chen, Kun Ya, Oak Chong, Sandra Gross. It is licensed under the terms of the MIT license.Creditsmathdistopswas created with a template toolcookiecutterand thepy-pkgs-cookiecuttertemplate.