BvChenpy 0.1.0__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.
bvchenpy-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Mukul Bijalwan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,198 @@
1
+ Metadata-Version: 2.4
2
+ Name: BvChenpy
3
+ Version: 0.1.0
4
+ Summary: Bivariate Chen distribution: density, CDF, survival, random generation, marginals, conditionals, moments, survival copula, and EM-based maximum-likelihood estimation.
5
+ Author-email: Mukul Bijalwan <mukulbijalwan555@gmail.com>, Puneet Kumar Gupta <puneetstat999@gmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/MukulBijalwan/BvChenpy
8
+ Project-URL: Documentation, https://github.com/MukulBijalwan/BvChenpy#readme
9
+ Project-URL: Bug Tracker, https://github.com/MukulBijalwan/BvChenpy/issues
10
+ Keywords: bivariate,Chen distribution,bathtub hazard,reliability,survival analysis,Marshall-Olkin,EM algorithm,statistics
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
20
+ Requires-Python: >=3.9
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Requires-Dist: numpy>=1.22
24
+ Requires-Dist: scipy>=1.8
25
+ Provides-Extra: plot
26
+ Requires-Dist: matplotlib>=3.5; extra == "plot"
27
+ Provides-Extra: test
28
+ Requires-Dist: pytest>=7.0; extra == "test"
29
+ Requires-Dist: matplotlib>=3.5; extra == "test"
30
+ Dynamic: license-file
31
+
32
+ # bvchen — The Bivariate Chen Distribution
33
+
34
+ [![CI](https://github.com/MukulBijalwan/bvchen/actions/workflows/ci.yml/badge.svg)](https://github.com/MukulBijalwan/bvchen/actions/workflows/ci.yml)
35
+ [![PyPI version](https://img.shields.io/pypi/v/bvchen.svg)](https://pypi.org/project/bvchen/)
36
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
37
+
38
+ **Authors:** Mukul Bijalwan ([mukulbijalwan555@gmail.com](mailto:mukulbijalwan555@gmail.com))
39
+ and Puneet Kumar Gupta ([puneetstat999@gmail.com](mailto:puneetstat999@gmail.com))
40
+
41
+ `bvchen` implements the **bivariate Chen (BvCh) distribution** introduced by
42
+ Gupta, Pundir, Sharma and Mesfioui (2022), together with the univariate
43
+ Chen (2000) building blocks. The distribution is constructed from three
44
+ independent Chen components `U_i ~ Chen(alpha_i, beta)` via
45
+
46
+ ```
47
+ Z1 = min(U1, U3), Z2 = min(U2, U3)
48
+ ```
49
+
50
+ It has **bathtub-shaped marginals hazards** (for `beta < 1`), closed-form
51
+ joint survival, a singular component on the diagonal `z1 = z2` of mass
52
+ `alpha3 / (alpha1 + alpha2 + alpha3)`, and is the natural bivariate
53
+ extension of the bathtub-shaped Chen lifetime model.
54
+
55
+ ## Features
56
+
57
+ - Joint density (`dbvch`), CDF (`pbvch`), survival function (`sbvch`) and
58
+ random generation (`rbvch`)
59
+ - Marginal distributions: `Z1 ~ Chen(alpha1+alpha3, beta)`,
60
+ `Z2 ~ Chen(alpha2+alpha3, beta)`
61
+ - Conditional densities with their diagonal atom and conditional hazards
62
+ - Raw joint moments `E[Z1^r Z2^s]` on a numerically stable exponential
63
+ scale; means, variances and covariance matrix
64
+ - Survival copula (Marshall-Olkin form) and Kendall's tau
65
+ - Maximum-likelihood estimation via the **EM algorithm**
66
+ (`fit_bvchen`) with profile likelihood for the power parameter
67
+ - Goodness-of-fit tools: Kolmogorov-Smirnov tests for both marginals and
68
+ the minimum, Q-Q plots, density surface and contour plots
69
+
70
+ ## Installation
71
+
72
+ ```bash
73
+ pip install bvchen
74
+ ```
75
+
76
+ For the plotting helpers install the extras:
77
+
78
+ ```bash
79
+ pip install "bvchen[plot]"
80
+ ```
81
+
82
+ ## Quick start
83
+
84
+ ```python
85
+ import numpy as np
86
+ import bvchen
87
+
88
+ # frozen distribution object
89
+ dist = bvchen.BvChen(alpha1=0.8, alpha2=1.2, alpha3=0.5, beta=1.5)
90
+
91
+ dist.pdf(0.5, 0.7) # joint density at (z1, z2)
92
+ dist.cdf(1.0, 1.5) # joint CDF
93
+ dist.sf(1.0, 1.5) # joint survival
94
+ sim = dist.rvs(500, random_state=42) # n x 2 matrix (columns z1, z2)
95
+
96
+ dist.mean() # [E(Z1), E(Z2)]
97
+ dist.cov() # variance-covariance matrix
98
+ dist.kendall_tau(random_state=0)
99
+ ```
100
+
101
+ ### Fitting to data with the EM algorithm
102
+
103
+ ```python
104
+ from bvchen import rbvch, fit_bvchen, gof, qqplot
105
+
106
+ # simulate from a known law ...
107
+ data = rbvch(400, 0.8, 1.2, 0.5, 1.5, random_state=2024)
108
+
109
+ # ... and recover the parameters by maximum likelihood (EM)
110
+ fit = fit_bvchen(data[:, 0], data[:, 1])
111
+ print(fit.coefficients) # close to (0.8, 1.2, 0.5, 1.5)
112
+ print(fit.loglik, fit.converged, fit.tau)
113
+
114
+ gof(data[:, 0], data[:, 1], *fit.coefficients) # KS tests
115
+ qqplot(data[:, 0], data[:, 1], *fit.coefficients) # Q-Q panels
116
+ ```
117
+
118
+ ### Functional interface
119
+
120
+ All routines are also available as plain functions mirroring the classic
121
+ R-style `d/p/q/r` naming:
122
+
123
+ ```python
124
+ from bvchen import dbvch, pbvch, sbvch, rbvch
125
+ from bvchen import dcond1, hcond1, survcop, bvch_moment
126
+
127
+ dbvch(0.5, 0.5, 1, 1, 1, 1.5, component="sing") # diagonal singular part
128
+ dcond1([0.4, 0.9, 1.2], y=1.0, alpha1=1, alpha2=1, alpha3=1, beta=1.5)
129
+ survcop(0.5, 0.6, 1, 1, 1) # survival copula
130
+ bvch_moment(r=1, s=1, alpha1=1, alpha2=1, alpha3=1, beta=1.5)
131
+ ```
132
+
133
+ ## Mathematical summary
134
+
135
+ With `u(z) = exp(z^beta) - 1`:
136
+
137
+ | Object | Formula |
138
+ | --- | --- |
139
+ | joint survival | `S(z1,z2) = exp{-(a1+a3)u(z1) - (a2+a3)u(z2) + a3 u(min(z1,z2))}` |
140
+ | density on `{z1<z2}` | `f_Ch(z1; a1) f_Ch(z2; a2+a3)` |
141
+ | density on `{z1>z2}` | `f_Ch(z1; a1+a3) f_Ch(z2; a2)` |
142
+ | singular density | `g(z) = a3 u'(z) exp{-A u(z)}`, mass `a3/A`, `A=a1+a2+a3` |
143
+ | marginals | `Z1~Ch(a1+a3,b)`, `Z2~Ch(a2+a3,b)`, `min(Z1,Z2)~Ch(A,b)` |
144
+ | survival copula | `C(u,v) = min(v u^(a1/(a1+a3)), u v^(a2/(a2+a3)))` |
145
+
146
+ ## References
147
+
148
+ - Gupta, P. K., Pundir, P. S., Sharma, V. K., Mesfioui, M. (2022).
149
+ *Bivariate extension of bathtub-shaped distribution.* Life Cycle
150
+ Reliability and Safety Engineering 11, 247-259.
151
+ <https://doi.org/10.1007/s41872-022-00193-4>
152
+ - Chen, Z. (2000). A new two-parameter lifetime distribution with bathtub
153
+ shape or increasing failure rate function. *Statistics & Probability
154
+ Letters* 49(2), 155-161.
155
+ - Meintanis, S. G. (2007). Test of fit for Marshall-Olkin distributions
156
+ with applications. *J. Stat. Comput. Simul.* 77, 171-179.
157
+
158
+ > Note: equation (14) of the 2022 paper misprints the copula exponents;
159
+ > this package uses the mathematically correct Marshall-Olkin form above,
160
+ > consistent with the construction.
161
+
162
+ ## Development
163
+
164
+ ```bash
165
+ git clone https://github.com/MukulBijalwan/bvchen
166
+ cd bvchen
167
+ pip install -e ".[test]"
168
+ pytest
169
+ ```
170
+
171
+ Build the distribution artifacts:
172
+
173
+ ```bash
174
+ pip install build
175
+ python -m build
176
+ ```
177
+
178
+ ## Citation
179
+
180
+ If you use this package in your research, please cite the paper that
181
+ introduced the distribution:
182
+
183
+ ```bibtex
184
+ @article{gupta2022bivariate,
185
+ author = {Gupta, Puneet Kumar and Pundir, Pramendra Singh and
186
+ Sharma, Vikas Kumar and Mesfioui, M.},
187
+ title = {Bivariate extension of bathtub-shaped distribution},
188
+ journal = {Life Cycle Reliability and Safety Engineering},
189
+ year = {2022},
190
+ volume = {11},
191
+ pages = {247--259},
192
+ doi = {10.1007/s41872-022-00193-4}
193
+ }
194
+ ```
195
+
196
+ ## License
197
+
198
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,167 @@
1
+ # bvchen — The Bivariate Chen Distribution
2
+
3
+ [![CI](https://github.com/MukulBijalwan/bvchen/actions/workflows/ci.yml/badge.svg)](https://github.com/MukulBijalwan/bvchen/actions/workflows/ci.yml)
4
+ [![PyPI version](https://img.shields.io/pypi/v/bvchen.svg)](https://pypi.org/project/bvchen/)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
6
+
7
+ **Authors:** Mukul Bijalwan ([mukulbijalwan555@gmail.com](mailto:mukulbijalwan555@gmail.com))
8
+ and Puneet Kumar Gupta ([puneetstat999@gmail.com](mailto:puneetstat999@gmail.com))
9
+
10
+ `bvchen` implements the **bivariate Chen (BvCh) distribution** introduced by
11
+ Gupta, Pundir, Sharma and Mesfioui (2022), together with the univariate
12
+ Chen (2000) building blocks. The distribution is constructed from three
13
+ independent Chen components `U_i ~ Chen(alpha_i, beta)` via
14
+
15
+ ```
16
+ Z1 = min(U1, U3), Z2 = min(U2, U3)
17
+ ```
18
+
19
+ It has **bathtub-shaped marginals hazards** (for `beta < 1`), closed-form
20
+ joint survival, a singular component on the diagonal `z1 = z2` of mass
21
+ `alpha3 / (alpha1 + alpha2 + alpha3)`, and is the natural bivariate
22
+ extension of the bathtub-shaped Chen lifetime model.
23
+
24
+ ## Features
25
+
26
+ - Joint density (`dbvch`), CDF (`pbvch`), survival function (`sbvch`) and
27
+ random generation (`rbvch`)
28
+ - Marginal distributions: `Z1 ~ Chen(alpha1+alpha3, beta)`,
29
+ `Z2 ~ Chen(alpha2+alpha3, beta)`
30
+ - Conditional densities with their diagonal atom and conditional hazards
31
+ - Raw joint moments `E[Z1^r Z2^s]` on a numerically stable exponential
32
+ scale; means, variances and covariance matrix
33
+ - Survival copula (Marshall-Olkin form) and Kendall's tau
34
+ - Maximum-likelihood estimation via the **EM algorithm**
35
+ (`fit_bvchen`) with profile likelihood for the power parameter
36
+ - Goodness-of-fit tools: Kolmogorov-Smirnov tests for both marginals and
37
+ the minimum, Q-Q plots, density surface and contour plots
38
+
39
+ ## Installation
40
+
41
+ ```bash
42
+ pip install bvchen
43
+ ```
44
+
45
+ For the plotting helpers install the extras:
46
+
47
+ ```bash
48
+ pip install "bvchen[plot]"
49
+ ```
50
+
51
+ ## Quick start
52
+
53
+ ```python
54
+ import numpy as np
55
+ import bvchen
56
+
57
+ # frozen distribution object
58
+ dist = bvchen.BvChen(alpha1=0.8, alpha2=1.2, alpha3=0.5, beta=1.5)
59
+
60
+ dist.pdf(0.5, 0.7) # joint density at (z1, z2)
61
+ dist.cdf(1.0, 1.5) # joint CDF
62
+ dist.sf(1.0, 1.5) # joint survival
63
+ sim = dist.rvs(500, random_state=42) # n x 2 matrix (columns z1, z2)
64
+
65
+ dist.mean() # [E(Z1), E(Z2)]
66
+ dist.cov() # variance-covariance matrix
67
+ dist.kendall_tau(random_state=0)
68
+ ```
69
+
70
+ ### Fitting to data with the EM algorithm
71
+
72
+ ```python
73
+ from bvchen import rbvch, fit_bvchen, gof, qqplot
74
+
75
+ # simulate from a known law ...
76
+ data = rbvch(400, 0.8, 1.2, 0.5, 1.5, random_state=2024)
77
+
78
+ # ... and recover the parameters by maximum likelihood (EM)
79
+ fit = fit_bvchen(data[:, 0], data[:, 1])
80
+ print(fit.coefficients) # close to (0.8, 1.2, 0.5, 1.5)
81
+ print(fit.loglik, fit.converged, fit.tau)
82
+
83
+ gof(data[:, 0], data[:, 1], *fit.coefficients) # KS tests
84
+ qqplot(data[:, 0], data[:, 1], *fit.coefficients) # Q-Q panels
85
+ ```
86
+
87
+ ### Functional interface
88
+
89
+ All routines are also available as plain functions mirroring the classic
90
+ R-style `d/p/q/r` naming:
91
+
92
+ ```python
93
+ from bvchen import dbvch, pbvch, sbvch, rbvch
94
+ from bvchen import dcond1, hcond1, survcop, bvch_moment
95
+
96
+ dbvch(0.5, 0.5, 1, 1, 1, 1.5, component="sing") # diagonal singular part
97
+ dcond1([0.4, 0.9, 1.2], y=1.0, alpha1=1, alpha2=1, alpha3=1, beta=1.5)
98
+ survcop(0.5, 0.6, 1, 1, 1) # survival copula
99
+ bvch_moment(r=1, s=1, alpha1=1, alpha2=1, alpha3=1, beta=1.5)
100
+ ```
101
+
102
+ ## Mathematical summary
103
+
104
+ With `u(z) = exp(z^beta) - 1`:
105
+
106
+ | Object | Formula |
107
+ | --- | --- |
108
+ | joint survival | `S(z1,z2) = exp{-(a1+a3)u(z1) - (a2+a3)u(z2) + a3 u(min(z1,z2))}` |
109
+ | density on `{z1<z2}` | `f_Ch(z1; a1) f_Ch(z2; a2+a3)` |
110
+ | density on `{z1>z2}` | `f_Ch(z1; a1+a3) f_Ch(z2; a2)` |
111
+ | singular density | `g(z) = a3 u'(z) exp{-A u(z)}`, mass `a3/A`, `A=a1+a2+a3` |
112
+ | marginals | `Z1~Ch(a1+a3,b)`, `Z2~Ch(a2+a3,b)`, `min(Z1,Z2)~Ch(A,b)` |
113
+ | survival copula | `C(u,v) = min(v u^(a1/(a1+a3)), u v^(a2/(a2+a3)))` |
114
+
115
+ ## References
116
+
117
+ - Gupta, P. K., Pundir, P. S., Sharma, V. K., Mesfioui, M. (2022).
118
+ *Bivariate extension of bathtub-shaped distribution.* Life Cycle
119
+ Reliability and Safety Engineering 11, 247-259.
120
+ <https://doi.org/10.1007/s41872-022-00193-4>
121
+ - Chen, Z. (2000). A new two-parameter lifetime distribution with bathtub
122
+ shape or increasing failure rate function. *Statistics & Probability
123
+ Letters* 49(2), 155-161.
124
+ - Meintanis, S. G. (2007). Test of fit for Marshall-Olkin distributions
125
+ with applications. *J. Stat. Comput. Simul.* 77, 171-179.
126
+
127
+ > Note: equation (14) of the 2022 paper misprints the copula exponents;
128
+ > this package uses the mathematically correct Marshall-Olkin form above,
129
+ > consistent with the construction.
130
+
131
+ ## Development
132
+
133
+ ```bash
134
+ git clone https://github.com/MukulBijalwan/bvchen
135
+ cd bvchen
136
+ pip install -e ".[test]"
137
+ pytest
138
+ ```
139
+
140
+ Build the distribution artifacts:
141
+
142
+ ```bash
143
+ pip install build
144
+ python -m build
145
+ ```
146
+
147
+ ## Citation
148
+
149
+ If you use this package in your research, please cite the paper that
150
+ introduced the distribution:
151
+
152
+ ```bibtex
153
+ @article{gupta2022bivariate,
154
+ author = {Gupta, Puneet Kumar and Pundir, Pramendra Singh and
155
+ Sharma, Vikas Kumar and Mesfioui, M.},
156
+ title = {Bivariate extension of bathtub-shaped distribution},
157
+ journal = {Life Cycle Reliability and Safety Engineering},
158
+ year = {2022},
159
+ volume = {11},
160
+ pages = {247--259},
161
+ doi = {10.1007/s41872-022-00193-4}
162
+ }
163
+ ```
164
+
165
+ ## License
166
+
167
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,53 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "BvChenpy"
7
+ version = "0.1.0"
8
+ description = "Bivariate Chen distribution: density, CDF, survival, random generation, marginals, conditionals, moments, survival copula, and EM-based maximum-likelihood estimation."
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ license = "MIT"
12
+ authors = [
13
+ { name = "Mukul Bijalwan", email = "mukulbijalwan555@gmail.com" },
14
+ { name = "Puneet Kumar Gupta", email = "puneetstat999@gmail.com" },
15
+ ]
16
+ keywords = [
17
+ "bivariate", "Chen distribution", "bathtub hazard", "reliability",
18
+ "survival analysis", "Marshall-Olkin", "EM algorithm", "statistics",
19
+ ]
20
+ classifiers = [
21
+ "Development Status :: 4 - Beta",
22
+ "Intended Audience :: Science/Research",
23
+ "Programming Language :: Python :: 3",
24
+ "Programming Language :: Python :: 3.9",
25
+ "Programming Language :: Python :: 3.10",
26
+ "Programming Language :: Python :: 3.11",
27
+ "Programming Language :: Python :: 3.12",
28
+ "Programming Language :: Python :: 3.13",
29
+ "Topic :: Scientific/Engineering :: Mathematics",
30
+ ]
31
+ dependencies = [
32
+ "numpy>=1.22",
33
+ "scipy>=1.8",
34
+ ]
35
+
36
+ [project.optional-dependencies]
37
+ plot = ["matplotlib>=3.5"]
38
+ test = ["pytest>=7.0", "matplotlib>=3.5"]
39
+
40
+ [project.urls]
41
+ Homepage = "https://github.com/MukulBijalwan/BvChenpy"
42
+ Documentation = "https://github.com/MukulBijalwan/BvChenpy#readme"
43
+ "Bug Tracker" = "https://github.com/MukulBijalwan/BvChenpy/issues"
44
+
45
+ [tool.setuptools.packages.find]
46
+ where = ["src"]
47
+
48
+ [tool.setuptools.package-data]
49
+ bvchen = ["py.typed"]
50
+
51
+ [tool.pytest.ini_options]
52
+ testpaths = ["tests"]
53
+ addopts = "-ra --strict-markers"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,198 @@
1
+ Metadata-Version: 2.4
2
+ Name: BvChenpy
3
+ Version: 0.1.0
4
+ Summary: Bivariate Chen distribution: density, CDF, survival, random generation, marginals, conditionals, moments, survival copula, and EM-based maximum-likelihood estimation.
5
+ Author-email: Mukul Bijalwan <mukulbijalwan555@gmail.com>, Puneet Kumar Gupta <puneetstat999@gmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/MukulBijalwan/BvChenpy
8
+ Project-URL: Documentation, https://github.com/MukulBijalwan/BvChenpy#readme
9
+ Project-URL: Bug Tracker, https://github.com/MukulBijalwan/BvChenpy/issues
10
+ Keywords: bivariate,Chen distribution,bathtub hazard,reliability,survival analysis,Marshall-Olkin,EM algorithm,statistics
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
20
+ Requires-Python: >=3.9
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Requires-Dist: numpy>=1.22
24
+ Requires-Dist: scipy>=1.8
25
+ Provides-Extra: plot
26
+ Requires-Dist: matplotlib>=3.5; extra == "plot"
27
+ Provides-Extra: test
28
+ Requires-Dist: pytest>=7.0; extra == "test"
29
+ Requires-Dist: matplotlib>=3.5; extra == "test"
30
+ Dynamic: license-file
31
+
32
+ # bvchen — The Bivariate Chen Distribution
33
+
34
+ [![CI](https://github.com/MukulBijalwan/bvchen/actions/workflows/ci.yml/badge.svg)](https://github.com/MukulBijalwan/bvchen/actions/workflows/ci.yml)
35
+ [![PyPI version](https://img.shields.io/pypi/v/bvchen.svg)](https://pypi.org/project/bvchen/)
36
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
37
+
38
+ **Authors:** Mukul Bijalwan ([mukulbijalwan555@gmail.com](mailto:mukulbijalwan555@gmail.com))
39
+ and Puneet Kumar Gupta ([puneetstat999@gmail.com](mailto:puneetstat999@gmail.com))
40
+
41
+ `bvchen` implements the **bivariate Chen (BvCh) distribution** introduced by
42
+ Gupta, Pundir, Sharma and Mesfioui (2022), together with the univariate
43
+ Chen (2000) building blocks. The distribution is constructed from three
44
+ independent Chen components `U_i ~ Chen(alpha_i, beta)` via
45
+
46
+ ```
47
+ Z1 = min(U1, U3), Z2 = min(U2, U3)
48
+ ```
49
+
50
+ It has **bathtub-shaped marginals hazards** (for `beta < 1`), closed-form
51
+ joint survival, a singular component on the diagonal `z1 = z2` of mass
52
+ `alpha3 / (alpha1 + alpha2 + alpha3)`, and is the natural bivariate
53
+ extension of the bathtub-shaped Chen lifetime model.
54
+
55
+ ## Features
56
+
57
+ - Joint density (`dbvch`), CDF (`pbvch`), survival function (`sbvch`) and
58
+ random generation (`rbvch`)
59
+ - Marginal distributions: `Z1 ~ Chen(alpha1+alpha3, beta)`,
60
+ `Z2 ~ Chen(alpha2+alpha3, beta)`
61
+ - Conditional densities with their diagonal atom and conditional hazards
62
+ - Raw joint moments `E[Z1^r Z2^s]` on a numerically stable exponential
63
+ scale; means, variances and covariance matrix
64
+ - Survival copula (Marshall-Olkin form) and Kendall's tau
65
+ - Maximum-likelihood estimation via the **EM algorithm**
66
+ (`fit_bvchen`) with profile likelihood for the power parameter
67
+ - Goodness-of-fit tools: Kolmogorov-Smirnov tests for both marginals and
68
+ the minimum, Q-Q plots, density surface and contour plots
69
+
70
+ ## Installation
71
+
72
+ ```bash
73
+ pip install bvchen
74
+ ```
75
+
76
+ For the plotting helpers install the extras:
77
+
78
+ ```bash
79
+ pip install "bvchen[plot]"
80
+ ```
81
+
82
+ ## Quick start
83
+
84
+ ```python
85
+ import numpy as np
86
+ import bvchen
87
+
88
+ # frozen distribution object
89
+ dist = bvchen.BvChen(alpha1=0.8, alpha2=1.2, alpha3=0.5, beta=1.5)
90
+
91
+ dist.pdf(0.5, 0.7) # joint density at (z1, z2)
92
+ dist.cdf(1.0, 1.5) # joint CDF
93
+ dist.sf(1.0, 1.5) # joint survival
94
+ sim = dist.rvs(500, random_state=42) # n x 2 matrix (columns z1, z2)
95
+
96
+ dist.mean() # [E(Z1), E(Z2)]
97
+ dist.cov() # variance-covariance matrix
98
+ dist.kendall_tau(random_state=0)
99
+ ```
100
+
101
+ ### Fitting to data with the EM algorithm
102
+
103
+ ```python
104
+ from bvchen import rbvch, fit_bvchen, gof, qqplot
105
+
106
+ # simulate from a known law ...
107
+ data = rbvch(400, 0.8, 1.2, 0.5, 1.5, random_state=2024)
108
+
109
+ # ... and recover the parameters by maximum likelihood (EM)
110
+ fit = fit_bvchen(data[:, 0], data[:, 1])
111
+ print(fit.coefficients) # close to (0.8, 1.2, 0.5, 1.5)
112
+ print(fit.loglik, fit.converged, fit.tau)
113
+
114
+ gof(data[:, 0], data[:, 1], *fit.coefficients) # KS tests
115
+ qqplot(data[:, 0], data[:, 1], *fit.coefficients) # Q-Q panels
116
+ ```
117
+
118
+ ### Functional interface
119
+
120
+ All routines are also available as plain functions mirroring the classic
121
+ R-style `d/p/q/r` naming:
122
+
123
+ ```python
124
+ from bvchen import dbvch, pbvch, sbvch, rbvch
125
+ from bvchen import dcond1, hcond1, survcop, bvch_moment
126
+
127
+ dbvch(0.5, 0.5, 1, 1, 1, 1.5, component="sing") # diagonal singular part
128
+ dcond1([0.4, 0.9, 1.2], y=1.0, alpha1=1, alpha2=1, alpha3=1, beta=1.5)
129
+ survcop(0.5, 0.6, 1, 1, 1) # survival copula
130
+ bvch_moment(r=1, s=1, alpha1=1, alpha2=1, alpha3=1, beta=1.5)
131
+ ```
132
+
133
+ ## Mathematical summary
134
+
135
+ With `u(z) = exp(z^beta) - 1`:
136
+
137
+ | Object | Formula |
138
+ | --- | --- |
139
+ | joint survival | `S(z1,z2) = exp{-(a1+a3)u(z1) - (a2+a3)u(z2) + a3 u(min(z1,z2))}` |
140
+ | density on `{z1<z2}` | `f_Ch(z1; a1) f_Ch(z2; a2+a3)` |
141
+ | density on `{z1>z2}` | `f_Ch(z1; a1+a3) f_Ch(z2; a2)` |
142
+ | singular density | `g(z) = a3 u'(z) exp{-A u(z)}`, mass `a3/A`, `A=a1+a2+a3` |
143
+ | marginals | `Z1~Ch(a1+a3,b)`, `Z2~Ch(a2+a3,b)`, `min(Z1,Z2)~Ch(A,b)` |
144
+ | survival copula | `C(u,v) = min(v u^(a1/(a1+a3)), u v^(a2/(a2+a3)))` |
145
+
146
+ ## References
147
+
148
+ - Gupta, P. K., Pundir, P. S., Sharma, V. K., Mesfioui, M. (2022).
149
+ *Bivariate extension of bathtub-shaped distribution.* Life Cycle
150
+ Reliability and Safety Engineering 11, 247-259.
151
+ <https://doi.org/10.1007/s41872-022-00193-4>
152
+ - Chen, Z. (2000). A new two-parameter lifetime distribution with bathtub
153
+ shape or increasing failure rate function. *Statistics & Probability
154
+ Letters* 49(2), 155-161.
155
+ - Meintanis, S. G. (2007). Test of fit for Marshall-Olkin distributions
156
+ with applications. *J. Stat. Comput. Simul.* 77, 171-179.
157
+
158
+ > Note: equation (14) of the 2022 paper misprints the copula exponents;
159
+ > this package uses the mathematically correct Marshall-Olkin form above,
160
+ > consistent with the construction.
161
+
162
+ ## Development
163
+
164
+ ```bash
165
+ git clone https://github.com/MukulBijalwan/bvchen
166
+ cd bvchen
167
+ pip install -e ".[test]"
168
+ pytest
169
+ ```
170
+
171
+ Build the distribution artifacts:
172
+
173
+ ```bash
174
+ pip install build
175
+ python -m build
176
+ ```
177
+
178
+ ## Citation
179
+
180
+ If you use this package in your research, please cite the paper that
181
+ introduced the distribution:
182
+
183
+ ```bibtex
184
+ @article{gupta2022bivariate,
185
+ author = {Gupta, Puneet Kumar and Pundir, Pramendra Singh and
186
+ Sharma, Vikas Kumar and Mesfioui, M.},
187
+ title = {Bivariate extension of bathtub-shaped distribution},
188
+ journal = {Life Cycle Reliability and Safety Engineering},
189
+ year = {2022},
190
+ volume = {11},
191
+ pages = {247--259},
192
+ doi = {10.1007/s41872-022-00193-4}
193
+ }
194
+ ```
195
+
196
+ ## License
197
+
198
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,20 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/BvChenpy.egg-info/PKG-INFO
5
+ src/BvChenpy.egg-info/SOURCES.txt
6
+ src/BvChenpy.egg-info/dependency_links.txt
7
+ src/BvChenpy.egg-info/requires.txt
8
+ src/BvChenpy.egg-info/top_level.txt
9
+ src/bvchen/__init__.py
10
+ src/bvchen/_utils.py
11
+ src/bvchen/chen.py
12
+ src/bvchen/diagnostics.py
13
+ src/bvchen/distribution.py
14
+ src/bvchen/estimation.py
15
+ src/bvchen/plotting.py
16
+ src/bvchen/py.typed
17
+ tests/test_bvchen.py
18
+ tests/test_chen.py
19
+ tests/test_diagnostics.py
20
+ tests/test_estimation.py
@@ -0,0 +1,9 @@
1
+ numpy>=1.22
2
+ scipy>=1.8
3
+
4
+ [plot]
5
+ matplotlib>=3.5
6
+
7
+ [test]
8
+ pytest>=7.0
9
+ matplotlib>=3.5
@@ -0,0 +1 @@
1
+ bvchen