python-synthetica 0.1.1__tar.gz → 0.1.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-synthetica
3
- Version: 0.1.1
3
+ Version: 0.1.3
4
4
  Summary: Generate synthetic time series data.
5
5
  Home-page: https://github.com/ActurialCapital/synthetica
6
6
  License: BSD 3-Clause License
@@ -13,7 +13,6 @@ Classifier: Programming Language :: Python :: 3.12
13
13
  Requires-Dist: numpy (>=1.26.4,<2.0.0)
14
14
  Requires-Dist: pandas (>=2.2.2,<3.0.0)
15
15
  Requires-Dist: scipy (>=1.13.1,<2.0.0)
16
- Requires-Dist: statsmodels (>=0.14.2,<0.15.0)
17
16
  Project-URL: Repository, https://github.com/ActurialCapital/synthetica
18
17
  Description-Content-Type: text/markdown
19
18
 
@@ -22,6 +21,14 @@ Description-Content-Type: text/markdown
22
21
  <!-- PROJECT LOGO -->
23
22
  <p align="center"><img src="https://github.com/ActurialCapital/synthetica/blob/main/docs/static/logo.png" alt="logo" width="90%" height="90%"></p>
24
23
 
24
+ | Overview | |
25
+ |---|---|
26
+ | **Open Source** | [![BSD 3-clause](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://github.com/ActurialCapital/synthetica/blob/main/LICENSE) |
27
+ | **Code** | [![!pypi](https://img.shields.io/pypi/v/python-synthetica?color=orange)](https://pypi.org/project/python-synthetica/) [![!python-versions](https://img.shields.io/pypi/pyversions/python-synthetica)](https://www.python.org/) |
28
+ | **CI/CD** | [![!codecov](https://img.shields.io/codecov/c/github/ActurialCapital/synthetica?label=codecov&logo=codecov)](https://codecov.io/gh/ActurialCapital/synthetica) |
29
+ | **Downloads** | ![PyPI - Downloads](https://img.shields.io/pypi/dw/python-synthetica) ![PyPI - Downloads](https://img.shields.io/pypi/dm/python-synthetica) [![Downloads](https://static.pepy.tech/personalized-badge/python-synthetica?period=total&units=international_system&left_color=grey&right_color=blue&left_text=cumulative%20(pypi))](https://pepy.tech/project/python-synthetica) |
30
+
31
+
25
32
  <!-- TABLE OF CONTENTS -->
26
33
  <details>
27
34
  <summary>Table of Contents</summary>
@@ -54,12 +61,12 @@ Description-Content-Type: text/markdown
54
61
  The project latest version incorporates a wide array of models, offering an extensive toolkit for generating synthetic time series data. This version includes features like:
55
62
 
56
63
  * `GeometricBrownianMotion`
57
- * `AR` (Auto Regressive)
58
- * `NARMA` (Non-Linear Auto Regressive Moving Average)
64
+ * `AutoRegressive`
65
+ * `NARMA`
59
66
  * `Heston`
60
- * `CIR` (Cox–Ingersoll–Ross)
67
+ * `CIR`
61
68
  * `LevyStable`
62
- * `MeanReverting` (Ornstein–Uhlenbeck)
69
+ * `MeanReverting`
63
70
  * `Merton`
64
71
  * `Poisson`
65
72
  * `Seasonal`
@@ -120,13 +127,42 @@ In this example, we are using the following parameters for illustration purposes
120
127
  >>> model.transform(matrix) # Produces highly positively correlated features
121
128
  ```
122
129
 
123
-
124
-
125
130
  <p align="center"><img src="https://github.com/ActurialCapital/synthetica/blob/main/docs/static/gbm_corr_transform.png" alt="chart-2" width="75%" height="75%"></p>
126
131
 
127
132
 
128
133
  <p align="right">(<a href="#readme-top">back to top</a>)</p>
129
134
 
135
+ ## Positive Definiteness
136
+
137
+ ### What positive definite means in a covariance matrix
138
+
139
+ A covariance matrix is considered positive definite if it satisfies the following key properties:
140
+
141
+ 1. It is symmetric, meaning the matrix is equal to its transpose.
142
+ 2. For any non-zero vector $x$, $x^T * C * x > 0$, where $C$ is the covariance matrix and $x^T$ is the transpose of $x$.
143
+ 3. All of its eigenvalues are strictly positive.
144
+
145
+ Positive definiteness in a covariance matrix has important implications:
146
+
147
+ 1. It ensures the matrix is invertible, which is crucial for many [statistical techniques](https://stats.stackexchange.com/questions/52976/is-a-sample-covariance-matrix-always-symmetric-and-positive-definite).
148
+ 2. It guarantees that the matrix represents a [valid probability distribution](https://statproofbook.github.io/P/covmat-psd.html).
149
+ 3. It allows for unique solutions in [optimization problems](https://gowrishankar.info/blog/why-covariance-matrix-should-be-positive-semi-definite-tests-using-breast-cancer-dataset/) and ensures the stability of certain algorithms.
150
+ 4. It indicates that no linear combination of the variables has zero variance, meaning all variables contribute [meaningful information](https://math.stackexchange.com/questions/114072/what-is-the-proof-that-covariance-matrices-are-always-semi-definite).
151
+
152
+ A covariance matrix that is positive semi-definite (allowing for eigenvalues to be non-negative rather than strictly positive) is still valid, but may indicate linear dependencies among variables.
153
+
154
+ In practice, sample covariance matrices are often positive definite if the number of observations exceeds the number of variables and there are no perfect linear relationships among the variables.
155
+
156
+ ### Implementation
157
+
158
+ `synthetica` automatically finds the nearest positive-definite matrix to input using `nearest_positive_definite` python function. it is directly sourced from [Computing a nearest symmetric positive semidefinite matrix](https://doi.org/10.1016/0024-3795(88)90223-6).
159
+
160
+ ### Other Sources
161
+
162
+ * [Matlab code](https://www.mathworks.com/matlabcentral/fileexchange/42885-nearestspd)
163
+ * [Stackoverflow](https://stackoverflow.com/.../python-convert-matrix-to-positive-semi-definite)
164
+ * [Gist](https://gist.github.com/fasiha/fdb5cec2054e6f1c6ae35476045a0bbd)
165
+
130
166
  <!-- CONTRIBUTING -->
131
167
  ## Contributing
132
168
 
@@ -3,6 +3,14 @@
3
3
  <!-- PROJECT LOGO -->
4
4
  <p align="center"><img src="https://github.com/ActurialCapital/synthetica/blob/main/docs/static/logo.png" alt="logo" width="90%" height="90%"></p>
5
5
 
6
+ | Overview | |
7
+ |---|---|
8
+ | **Open Source** | [![BSD 3-clause](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://github.com/ActurialCapital/synthetica/blob/main/LICENSE) |
9
+ | **Code** | [![!pypi](https://img.shields.io/pypi/v/python-synthetica?color=orange)](https://pypi.org/project/python-synthetica/) [![!python-versions](https://img.shields.io/pypi/pyversions/python-synthetica)](https://www.python.org/) |
10
+ | **CI/CD** | [![!codecov](https://img.shields.io/codecov/c/github/ActurialCapital/synthetica?label=codecov&logo=codecov)](https://codecov.io/gh/ActurialCapital/synthetica) |
11
+ | **Downloads** | ![PyPI - Downloads](https://img.shields.io/pypi/dw/python-synthetica) ![PyPI - Downloads](https://img.shields.io/pypi/dm/python-synthetica) [![Downloads](https://static.pepy.tech/personalized-badge/python-synthetica?period=total&units=international_system&left_color=grey&right_color=blue&left_text=cumulative%20(pypi))](https://pepy.tech/project/python-synthetica) |
12
+
13
+
6
14
  <!-- TABLE OF CONTENTS -->
7
15
  <details>
8
16
  <summary>Table of Contents</summary>
@@ -35,12 +43,12 @@
35
43
  The project latest version incorporates a wide array of models, offering an extensive toolkit for generating synthetic time series data. This version includes features like:
36
44
 
37
45
  * `GeometricBrownianMotion`
38
- * `AR` (Auto Regressive)
39
- * `NARMA` (Non-Linear Auto Regressive Moving Average)
46
+ * `AutoRegressive`
47
+ * `NARMA`
40
48
  * `Heston`
41
- * `CIR` (Cox–Ingersoll–Ross)
49
+ * `CIR`
42
50
  * `LevyStable`
43
- * `MeanReverting` (Ornstein–Uhlenbeck)
51
+ * `MeanReverting`
44
52
  * `Merton`
45
53
  * `Poisson`
46
54
  * `Seasonal`
@@ -101,13 +109,42 @@ In this example, we are using the following parameters for illustration purposes
101
109
  >>> model.transform(matrix) # Produces highly positively correlated features
102
110
  ```
103
111
 
104
-
105
-
106
112
  <p align="center"><img src="https://github.com/ActurialCapital/synthetica/blob/main/docs/static/gbm_corr_transform.png" alt="chart-2" width="75%" height="75%"></p>
107
113
 
108
114
 
109
115
  <p align="right">(<a href="#readme-top">back to top</a>)</p>
110
116
 
117
+ ## Positive Definiteness
118
+
119
+ ### What positive definite means in a covariance matrix
120
+
121
+ A covariance matrix is considered positive definite if it satisfies the following key properties:
122
+
123
+ 1. It is symmetric, meaning the matrix is equal to its transpose.
124
+ 2. For any non-zero vector $x$, $x^T * C * x > 0$, where $C$ is the covariance matrix and $x^T$ is the transpose of $x$.
125
+ 3. All of its eigenvalues are strictly positive.
126
+
127
+ Positive definiteness in a covariance matrix has important implications:
128
+
129
+ 1. It ensures the matrix is invertible, which is crucial for many [statistical techniques](https://stats.stackexchange.com/questions/52976/is-a-sample-covariance-matrix-always-symmetric-and-positive-definite).
130
+ 2. It guarantees that the matrix represents a [valid probability distribution](https://statproofbook.github.io/P/covmat-psd.html).
131
+ 3. It allows for unique solutions in [optimization problems](https://gowrishankar.info/blog/why-covariance-matrix-should-be-positive-semi-definite-tests-using-breast-cancer-dataset/) and ensures the stability of certain algorithms.
132
+ 4. It indicates that no linear combination of the variables has zero variance, meaning all variables contribute [meaningful information](https://math.stackexchange.com/questions/114072/what-is-the-proof-that-covariance-matrices-are-always-semi-definite).
133
+
134
+ A covariance matrix that is positive semi-definite (allowing for eigenvalues to be non-negative rather than strictly positive) is still valid, but may indicate linear dependencies among variables.
135
+
136
+ In practice, sample covariance matrices are often positive definite if the number of observations exceeds the number of variables and there are no perfect linear relationships among the variables.
137
+
138
+ ### Implementation
139
+
140
+ `synthetica` automatically finds the nearest positive-definite matrix to input using `nearest_positive_definite` python function. it is directly sourced from [Computing a nearest symmetric positive semidefinite matrix](https://doi.org/10.1016/0024-3795(88)90223-6).
141
+
142
+ ### Other Sources
143
+
144
+ * [Matlab code](https://www.mathworks.com/matlabcentral/fileexchange/42885-nearestspd)
145
+ * [Stackoverflow](https://stackoverflow.com/.../python-convert-matrix-to-positive-semi-definite)
146
+ * [Gist](https://gist.github.com/fasiha/fdb5cec2054e6f1c6ae35476045a0bbd)
147
+
111
148
  <!-- CONTRIBUTING -->
112
149
  ## Contributing
113
150
 
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "python-synthetica"
3
- version = "0.1.1"
3
+ version = "0.1.3"
4
4
  description = "Generate synthetic time series data."
5
5
  authors = ["ActurialCapital"]
6
6
  license = "BSD 3-Clause License"
@@ -13,7 +13,6 @@ python = "^3.11"
13
13
  numpy = "^1.26.4"
14
14
  pandas = "^2.2.2"
15
15
  scipy = "^1.13.1"
16
- statsmodels = "^0.14.2"
17
16
 
18
17
  [build-system]
19
18
  requires = ["poetry-core"]
@@ -227,7 +227,8 @@ class BaseSynthetic(ABC):
227
227
 
228
228
  return self.to_pandas(np.array(extracted_paths).T)
229
229
 
230
- def cholesky_transform(self, rvs: np.array, matrix: np.array) -> np.ndarray:
230
+ @staticmethod
231
+ def cholesky_transform(rvs: np.array, matrix: np.array) -> np.ndarray:
231
232
  """
232
233
  Perform Cholesky transformation on random variables.
233
234
 
@@ -872,7 +872,7 @@ class MeanReverting(BaseSynthetic):
872
872
  return self.to_pandas(paths[1:,])
873
873
 
874
874
 
875
- class AR(BaseSynthetic):
875
+ class AutoRegressive(BaseSynthetic):
876
876
  """
877
877
  A class for generating synthetic autoregressive (AR) model.
878
878