Skip to content

Commit bd1e67c

Browse files
feat: add stats/base/dists/burr-type3/cdf
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 380e8ea commit bd1e67c

File tree

4 files changed

+192
-9
lines changed

4 files changed

+192
-9
lines changed
Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
<!--
2+
3+
@license Apache-2.0
4+
5+
Copyright (c) 2018 The Stdlib Authors.
6+
7+
Licensed under the Apache License, Version 2.0 (the "License");
8+
you may not use this file except in compliance with the License.
9+
You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
19+
-->
20+
21+
# Cumulative Distribution Function
22+
23+
> [Burr (type III)][burr-distribution] distribution [cumulative distribution function][cdf].
24+
25+
<section class="intro">
26+
27+
The [cumulative distribution function][cdf] for a [Burr (type III)][burr-distribution] random variable is
28+
29+
<!-- <equation class="equation" label="eq:burr-type3_cdf" align="center"
30+
raw="F(x; c, d) = (1 + x^{-c})^{-d}"
31+
alt="Cumulative distribution function for a Burr (Type III) distribution."> -->
32+
33+
```math
34+
F(x; alpha, beta) = (1 + x^{-alpha})^{-beta}
35+
```
36+
37+
<!-- <div class="equation" align="center" data-raw-text="F(x;c,d) = (1 + x^{-c})^{-d}" data-equation="eq:burr-type3_cdf">
38+
<img src="https://quicklatex.com/cache3/1e/ql_96e6c56a3c01ce5db3f378b28ee9511e_l3.png" alt="Cumulative distribution function for a Burr (Type III) distribution.">
39+
<br>
40+
</div> -->
41+
42+
<!-- </equation> -->
43+
44+
where `alpha > 0` is the first shape parameter and `beta > 0` is the second shape parameter.
45+
46+
</section>
47+
48+
<!-- /.intro -->
49+
50+
<section class="usage">
51+
52+
## Usage
53+
54+
```javascript
55+
var cdf = require( '@stdlib/stats/base/dists/burr-type3/cdf' );
56+
```
57+
58+
#### cdf( x, alpha, beta )
59+
60+
Evaluates the [cumulative distribution function][cdf] (CDF) for a [Burr (type III)][burr-distribution] distribution with parameters `alpha` (first shape parameter) and `beta` (second shape parameter).
61+
62+
```javascript
63+
var y = cdf( 0.1, 1.0, 1.0 );
64+
// returns ~0.09
65+
66+
y = cdf( 0.2, 2.0, 2.0 );
67+
// returns ~0.0015
68+
69+
y = cdf( 0.4, 4.0, 4.0 );
70+
// returns ~3.88e-7
71+
72+
y = cdf( 1.0, 0.1, 1.0 );
73+
// returns 0.5
74+
75+
y = cdf( 0.3, 0.5, 0.5 );
76+
// returns ~0.59
77+
78+
y = cdf( 0.5, 1.0, 1.0 );
79+
// returns ~0.33
80+
81+
y = cdf( 0.5, 2.0, 4.0 );
82+
// returns ~0.0016
83+
84+
y = cdf( 0.8, 0.5, 0.5 );
85+
// returns ~0.69
86+
```
87+
88+
If provided `NaN` as any argument, the function returns `NaN`.
89+
90+
```javascript
91+
var y = cdf( NaN, 1.0, 1.0 );
92+
// returns NaN
93+
94+
y = cdf( 0.0, NaN, 1.0 );
95+
// returns NaN
96+
97+
y = cdf( 0.0, 1.0, NaN );
98+
// returns NaN
99+
```
100+
101+
If provided `alpha <= 0`, the function returns `NaN`.
102+
103+
```javascript
104+
var y = cdf( 2.0, -1.0, 0.5 );
105+
// returns NaN
106+
107+
y = cdf( 2.0, 0.0, 0.5 );
108+
// returns NaN
109+
```
110+
111+
If provided `beta <= 0`, the function returns `NaN`.
112+
113+
```javascript
114+
var y = cdf( 2.0, 0.5, -1.0 );
115+
// returns NaN
116+
117+
y = cdf( 2.0, 0.5, 0.0 );
118+
// returns NaN
119+
```
120+
121+
#### cdf.factory( alpha, beta )
122+
123+
Returns a function for evaluating the [cumulative distribution function][cdf] for a [Burr (type III)][burr-distribution] distribution with parameters `alpha` (first shape parameter) and `beta` (second shape parameter).
124+
125+
```javascript
126+
var mycdf = cdf.factory( 0.5, 0.5 );
127+
128+
var y = mycdf( 0.8 );
129+
// returns ~0.69
130+
131+
y = mycdf( 0.3 );
132+
// returns ~0.59
133+
```
134+
135+
</section>
136+
137+
<!-- /.usage -->
138+
139+
<section class="examples">
140+
141+
## Examples
142+
143+
<!-- eslint no-undef: "error" -->
144+
145+
```javascript
146+
var cdf = require( '@stdlib/stats/base/dists/burr-type3/cdf' );
147+
var linspace = require( '@stdlib/array/linspace' );
148+
149+
var alpha = linspace( 1, 10.0, 10 );
150+
var beta = linspace( 1, 10.0, 10 );
151+
var x = linspace( 0.1, 1.0, 10 );
152+
var y;
153+
var i;
154+
155+
for ( i = 0; i < 10; i++ ) {
156+
y = cdf( x[ i ], alpha[ i ], beta[ i ] );
157+
console.log( 'x: %d, α: %d, β: %d, F(x;α,β): %d', x[i].toFixed( 4 ), alpha[i].toFixed( 4 ), beta[i].toFixed( 4 ), y.toFixed( 4 ) );
158+
}
159+
```
160+
161+
</section>
162+
163+
<!-- /.examples -->
164+
165+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
166+
167+
<section class="related">
168+
169+
</section>
170+
171+
<!-- /.related -->
172+
173+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
174+
175+
<section class="links">
176+
177+
[burr-distribution]: https://en.wikipedia.org/wiki/Burr_distribution
178+
179+
[cdf]: https://en.wikipedia.org/wiki/Cumulative_distribution_function
180+
181+
</section>
182+
183+
<!-- /.links -->

lib/node_modules/@stdlib/stats/base/dists/burr-type3/cdf/examples/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ var i;
2929

3030
for ( i = 0; i < 10; i++ ) {
3131
y = cdf( x[ i ], alpha[ i ], beta[ i ] );
32-
console.log( 'x: %d, α: %d, β: %d, F(x;α,β): %d', x[i].toFixed( 4 ), alpha[i].toFixed( 4 ), beta[i].toFixed( 4 ), y );
32+
console.log( 'x: %d, α: %d, β: %d, F(x;α,β): %d', x[i].toFixed( 4 ), alpha[i].toFixed( 4 ), beta[i].toFixed( 4 ), y.toFixed( 4 ) );
3333
}

lib/node_modules/@stdlib/stats/base/dists/burr-type3/cdf/test/test.cdf.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ tape( 'the function evaluates the cdf for `x` given small parameters `c` and `d`
126126
t.equal( y, expected[i], 'x: '+x[i]+'. c:'+c[i]+'. d:'+d[i]+', y: '+y+', expected: '+expected[i] );
127127
} else {
128128
delta = abs( y - expected[ i ] );
129-
tol = 2 * EPS * abs( expected[ i ] );
129+
tol = 2.0 * EPS * abs( expected[ i ] );
130130
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. c: '+c[i]+'. d: '+d[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
131131
}
132132
}
@@ -153,7 +153,7 @@ tape( 'the function evaluates the cdf for `x` given medium parameters `c` and `d
153153
t.equal( y, expected[i], 'x: '+x[i]+'. c:'+c[i]+'. d:'+d[i]+', y: '+y+', expected: '+expected[i] );
154154
} else {
155155
delta = abs( y - expected[ i ] );
156-
tol = 5 * EPS * abs( expected[ i ] );
156+
tol = 5.0 * EPS * abs( expected[ i ] );
157157
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. c: '+c[i]+'. d: '+d[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
158158
}
159159
}
@@ -180,7 +180,7 @@ tape( 'the function evaluates the cdf for `x` given large parameters `c` and `d`
180180
t.equal( y, expected[i], 'x: '+x[i]+'. c: '+c[i]+'. d: '+d[i]+', y: '+y+', expected: '+expected[i] );
181181
} else {
182182
delta = abs( y - expected[ i ] );
183-
tol = 12 * EPS * abs( expected[ i ] );
183+
tol = 12.0 * EPS * abs( expected[ i ] );
184184
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. c: '+c[i]+'. d: '+d[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
185185
}
186186
}

lib/node_modules/@stdlib/stats/base/dists/burr-type3/cdf/test/test.factory.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ tape( 'if provided a finite `c` and `d`, the function returns a function which r
129129
t.end();
130130
});
131131

132-
tape( 'the created function evaluates the cdf for `x` given small `c` and `d`', function test( t ) {
132+
tape( 'the created function evaluates the cdf for `x` given small parameters `c` and `d`', function test( t ) {
133133
var expected;
134134
var delta;
135135
var cdf;
@@ -158,7 +158,7 @@ tape( 'the created function evaluates the cdf for `x` given small `c` and `d`',
158158
t.end();
159159
});
160160

161-
tape( 'the created function evaluates the cdf for `x` given a medium `c`', function test( t ) {
161+
tape( 'the created function evaluates the cdf for `x` given medium parameters `c` and `d`', function test( t ) {
162162
var expected;
163163
var delta;
164164
var cdf;
@@ -180,14 +180,14 @@ tape( 'the created function evaluates the cdf for `x` given a medium `c`', funct
180180
t.equal( y, expected[i], 'x: '+x[i]+'. c: '+c[i]+'. d: '+d[i]+', y: '+y+', expected: '+expected[i] );
181181
} else {
182182
delta = abs( y - expected[ i ] );
183-
tol = 5 * EPS * abs( expected[ i ] );
183+
tol = 5.0 * EPS * abs( expected[ i ] );
184184
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. c: '+c[i]+'. d: '+d[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
185185
}
186186
}
187187
t.end();
188188
});
189189

190-
tape( 'the created function evaluates the cdf for `x` given a large `c`', function test( t ) {
190+
tape( 'the created function evaluates the cdf for `x` given large parameters `c` and `d`', function test( t ) {
191191
var expected;
192192
var delta;
193193
var cdf;
@@ -209,7 +209,7 @@ tape( 'the created function evaluates the cdf for `x` given a large `c`', functi
209209
t.equal( y, expected[i], 'x: '+x[i]+'. c: '+c[i]+'. d: '+d[i]+', y: '+y+', expected: '+expected[i] );
210210
} else {
211211
delta = abs( y - expected[ i ] );
212-
tol = 12 * EPS * abs( expected[ i ] );
212+
tol = 12.0 * EPS * abs( expected[ i ] );
213213
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. c: '+c[i]+'. d: '+d[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
214214
}
215215
}

0 commit comments

Comments
 (0)