Skip to content

Commit

Permalink
read the docs
Browse files Browse the repository at this point in the history
  • Loading branch information
tfm000 committed Nov 28, 2023
1 parent 8781456 commit d577b84
Show file tree
Hide file tree
Showing 13 changed files with 274 additions and 2 deletions.
13 changes: 13 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: 2

build:
os: "ubuntu-22.04"
tools:
python: "3.10"

python:
install:
- requirements: docs/requirements.txt

sphinx:
configuration: docs/source/conf.py
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<img src="https://img.shields.io/badge/license-MIT-brightgreen.svg"
alt="MIT license"></a> &nbsp;
<a href="https://github.com/tfm000/sklarpy/actions/workflows/tests.yml">
<img src="https://github.com/tfm000/sklarpy/actions/workflows/tests.yml/badge.svg"
<img src="https://github.com/tfm000/sklarpy/actions/workflows/tests.yml/badge.svg?branch=main"
alt="build"></a> &nbsp;
<a href="https://pepy.tech/project/sklarpy">
<img src="https://static.pepy.tech/personalized-badge/sklarpy?period=total&units=international_system&left_color=black&right_color=orange&left_text=Downloads"
Expand All @@ -29,9 +29,11 @@

SklarPy (pronounced 'Sky-Lar-Pee' or 'Sky-La-Pie') is an open-source software for probability distribution fitting.
It contains useful tools for fitting Copula, Multivariate and Univariate probability distributions.
In addition to over 100 univariate distributions, we implement many multivariate normal mixture distributions and their copulas, including Gaussian, Student-T, Skewed-T and Generalized Hyperbolic distributions and copulas.
In addition to over 100 univariate distributions, we implement many multivariate normal mixture distributions and their copulas, including Gaussian, Student-T, Skewed-T and Generalized Hyperbolic distributions.
Named after Sklar's theorem and Abe Sklar, the American mathematician who proved that multivariate cumulative distribution functions can be expressed in terms of copulas and their marginals.

This library has many different possible use cases, ranging from machine learning to finance.


## Table of contents

Expand Down Expand Up @@ -101,6 +103,7 @@ Further examples can be found <a href="https://github.com/tfm000/sklarpy/tree/ma
- We allow for easy plotting of all our distributions, allowing you to visualize your models.
- We use scipy.stats as a backend for all our univariate models, meaning as scipy expands and improves their model selection, so will ours!
- We provide multivariate and univariate distributions, in addition to our copula models, meaning SklarPy can act as a one-stop-shop for all probability distribution fitting. A full list of our implemented multivariate distributions can be found <a href="https://github.com/tfm000/sklarpy/tree/main/sklarpy/multivariate"> here</a>.
- We are continuing to expand our library, and are open to suggestions for new models to implement. If you have a model you would like to see implemented, please open an issue on our <a href="https://github.com/tfm000/sklarpy/issues">GitHub page</a>.

## Testing
All tests are written using pytest and cover all user accessible code.
Expand Down
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build

if "%1" == "" goto help

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
2 changes: 2 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sphinx==7.1.2
sphinx-rtd-theme==1.3.0rc1
5 changes: 5 additions & 0 deletions docs/source/Copulas.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.. _copulas:

##############
Copula Models
##############
19 changes: 19 additions & 0 deletions docs/source/Installation.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.. _installation:

Installation
------------

To use SklarPy, first install it using pip:

.. code-block:: text
pip install sklarpy
For Developers
--------------

If you wish to add your own significant modifications to SklarPy, you can can clone the current repository using:

.. code-block:: text
git clone https://github.com/tfm000/sklarpy
5 changes: 5 additions & 0 deletions docs/source/Misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.. _misc:

####################
Miscellaneous Tools
####################
5 changes: 5 additions & 0 deletions docs/source/Multivariate.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.. _multivariate:

############################
Multivariate Distributions
############################
6 changes: 6 additions & 0 deletions docs/source/Univariate.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.. _univariate:

#########################
Univariate Distributions
#########################

39 changes: 39 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Configuration file for the Sphinx documentation builder.
import os
import sys

sys.path.insert(0, os.path.abspath("..."))

# -- Project information

project = 'SklarPy'
copyright = '2023, Tyler Mitchell'
author = 'Tyler Mitchell'

release = '1.0.0'
version = '1.0.0'

# -- General configuration

extensions = [
'sphinx.ext.duration',
'sphinx.ext.doctest',
'sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.intersphinx',
]

intersphinx_mapping = {
'python': ('https://docs.python.org/3/', None),
'sphinx': ('https://www.sphinx-doc.org/en/master/', None),
}
intersphinx_disabled_domains = ['std']

templates_path = ['_templates']

# -- Options for HTML output

html_theme = 'sphinx_rtd_theme'

# -- Options for EPUB output
epub_show_urls = 'footnote'
117 changes: 117 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
.. image:: https://github.com/tfm000/sklarpy/blob/main/media/logo.png?raw=true
:alt: SklarPy logo
:scale: 60%
:align: center

.. raw:: html

<meta name="description" content="Copula, Multivariate and Univariate probability distribution fitting in Python.">
<meta name="keywords" content="SklarPy, Sklar, Copula, Copulas, Copulae, Probability, Distribution, Univariate, Bivariate, Multivariate, Joint, CDF, PDF, Modeling, Quantitative, Fitting, Statistics, Mathematics, Finance, Risk, VaR, Variables">
<meta name="author" content="Tyler Mitchell">

<embed>
<p align="center">
<a href="https://github.com/tfm000/sklarpy/blob/main/LICENSE">
<img src="https://img.shields.io/badge/license-MIT-brightgreen.svg"
alt="MIT license"></a> &nbsp;
<a href="https://github.com/tfm000/sklarpy/actions/workflows/tests.yml">
<img src="https://github.com/tfm000/sklarpy/actions/workflows/tests.yml/badge.svg"
alt="build"></a> &nbsp;
<a href="https://pepy.tech/project/sklarpy">
<img src="https://static.pepy.tech/personalized-badge/sklarpy?period=total&units=international_system&left_color=black&right_color=orange&left_text=Downloads"
alt="downloads"></a> &nbsp;
<a href="https://pypi.org/project/sklarpy/">
<img src="https://img.shields.io/badge/Maintained%3F-yes-green.svg"
alt="maintained"></a>
</p>

<p align="center">
<a href="https://pypi.org/project/sklarpy/">
<img src="https://img.shields.io/badge/mac%20os-000000?style=for-the-badge&logo=apple&logoColor=white"
alt="mac os"></a>
<a href="https://pypi.org/project/sklarpy/">
<img src="https://img.shields.io/badge/Windows-0078D6?style=for-the-badge&logo=windows&logoColor=white"
alt="windows"></a>
</p>
</embed>

SklarPy (pronounced 'Sky-Lar-Pee' or 'Sky-La-Pie') is an open-source software for probability distribution fitting.
It contains useful tools for fitting Copula, Multivariate and Univariate probability distributions.
In addition to over 100 univariate distributions, we implement many multivariate normal mixture distributions and their copulas, including Gaussian, Student-T, Skewed-T and Generalized Hyperbolic distributions.
Named after Sklar's theorem and Abe Sklar, the American mathematician who proved that multivariate cumulative distribution functions can be expressed in terms of copulas and their marginals.

This library has many different possible use cases, ranging from machine learning to finance.

Contents
--------

.. toctree::
:maxdepth: 2
Installation
Univariate
Multivariate
Copulas
Misc

Why we are better
-----------------
- Unlike other Python implementations of copulas, we implement more than the Gaussian and Archimedean copulas. A full list of our implementated copula models can be found in the documentation, though it includes many normal mean-variance mixture models as well as Archimedean and non-parametric models.
- We allow for easy parameter fitting of both the univariate marginals and the multivariate copula distribution.
- We allow for easy plotting of all our distributions, allowing you to visualize your models.
- We use scipy.stats as a backend for all our univariate models, meaning as scipy expands and improves their model selection, so will ours!
- We provide multivariate and univariate distributions, in addition to our copula models, meaning SklarPy can act as a one-stop-shop for all probability distribution fitting. A full list of our implemented multivariate distributions can be found in the documentation.
- We are continuing to expand our library, and are open to suggestions for new models to implement. If you have a model you would like to see implemented, please open an issue on our GitHub page.

Example
--------

Here we show a quick example of working with SklarPy.
For more information, see the specific documentaion.::

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklarpy.copulas import gh_copula

# generating random data
n: int = 1000
obs: np.ndarray = np.full((n, 2), np.nan)
obs[:, 0] = np.random.normal(3,4, size=(n,))
obs[:, 1] = obs[:, 0] + 0.5 * np.random.normal(3, 5, size=(n,))
obvs_df: pd.DataFrame = pd.DataFrame(obs, columns=['Process A', 'Process B'])

# fitting our copula model
fitted_copula = gh_copula.fit(obvs_df)

# printing our fitted copula parameters
print(fitted_copula.copula_params.to_dict)

# printing our fitted marginal distributions
print(fitted_copula.mdists)

# plotting our fit
fitted_copula.pdf_plot(show=False)
fitted_copula.copula_pdf_plot(show=False)
plt.show()

This outputs:

.. code-block:: text
{'lamb': -10.0, 'chi': 4.227038325195731, 'psi': 10.0,
'loc': array([[0.], [0.]]),
'shape': array([[1. , 0.84273015],
[0.84273015, 1.]]),
'gamma': array([[0.99696041], [0.99913161]])}
{0: lognorm(0.02, -203.22, 206.18), 1: lognorm(0.04, -110.89, 115.4)}
.. image:: https://github.com/tfm000/sklarpy/blob/main/media/PDF_Gh_PDF_Plot_Plot.png?raw=true
:alt: GH PDF
:scale: 60%
:align: center

.. image:: https://github.com/tfm000/sklarpy/blob/main/media/Copula_PDF_Gh_Copula_PDF_Plot_Plot.png?raw=true
:alt: GH Copula PDF
:scale: 60%
:align: center
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ dev = [
"pytest==7.1.2",
"tox==3.25.1",
]
docs = [
"sphinx~=4.2.0",
]

[project.urls] # Optional
"Homepage" = "https://github.com/tfm000/sklarpy"
Expand Down

0 comments on commit d577b84

Please sign in to comment.