Skip to content

Commit 63fcc9f

Browse files
committed
Auto-generated commit
1 parent 5cd0f2e commit 63fcc9f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+4809
-72
lines changed

.github/PULL_REQUEST_TEMPLATE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats) of the main repository where we’ll review and provide feedback.
44

5-
If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib.
5+
If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib.
66

77
We look forward to receiving your contribution! :smiley:

CHANGELOG.md

+145-2
Large diffs are not rendered by default.

base/README.md

+3-9
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ The namespace contains the following statistical functions:
7171
- <span class="signature">[`dmskmax( N, x, strideX, mask, strideMask )`][@stdlib/stats/base/dmskmax]</span><span class="delimiter">: </span><span class="description">calculate the maximum value of a double-precision floating-point strided array according to a mask.</span>
7272
- <span class="signature">[`dmskmin( N, x, strideX, mask, strideMask )`][@stdlib/stats/base/dmskmin]</span><span class="delimiter">: </span><span class="description">calculate the minimum value of a double-precision floating-point strided array according to a mask.</span>
7373
- <span class="signature">[`dmskrange( N, x, strideX, mask, strideMask )`][@stdlib/stats/base/dmskrange]</span><span class="delimiter">: </span><span class="description">calculate the range of a double-precision floating-point strided array according to a mask.</span>
74-
- <span class="signature">[`dnanmax( N, x, strideX )`][@stdlib/stats/strided/dnanmax]</span><span class="delimiter">: </span><span class="description">calculate the maximum value of a double-precision floating-point strided array, ignoring `NaN` values.</span>
75-
- <span class="signature">[`dnanmaxabs( N, x, strideX )`][@stdlib/stats/strided/dnanmaxabs]</span><span class="delimiter">: </span><span class="description">calculate the maximum absolute value of a double-precision floating-point strided array, ignoring `NaN` values.</span>
7674
- <span class="signature">[`dnanmean( N, x, strideX )`][@stdlib/stats/base/dnanmean]</span><span class="delimiter">: </span><span class="description">calculate the arithmetic mean of a double-precision floating-point strided array, ignoring `NaN` values.</span>
7775
- <span class="signature">[`dnanmeanors( N, x, strideX )`][@stdlib/stats/base/dnanmeanors]</span><span class="delimiter">: </span><span class="description">calculate the arithmetic mean of a double-precision floating-point strided array, ignoring `NaN` values and using ordinary recursive summation.</span>
7876
- <span class="signature">[`dnanmeanpn( N, x, strideX )`][@stdlib/stats/base/dnanmeanpn]</span><span class="delimiter">: </span><span class="description">calculate the arithmetic mean of a double-precision floating-point strided array, ignoring `NaN` values and using a two-pass error correction algorithm.</span>
@@ -132,19 +130,19 @@ The namespace contains the following statistical functions:
132130
- <span class="signature">[`maxBy( N, x, stride, clbk[, thisArg] )`][@stdlib/stats/base/max-by]</span><span class="delimiter">: </span><span class="description">calculate the maximum value of a strided array via a callback function.</span>
133131
- <span class="signature">[`max( N, x, strideX )`][@stdlib/stats/base/max]</span><span class="delimiter">: </span><span class="description">calculate the maximum value of a strided array.</span>
134132
- <span class="signature">[`maxabs( N, x, strideX )`][@stdlib/stats/base/maxabs]</span><span class="delimiter">: </span><span class="description">calculate the maximum absolute value of a strided array.</span>
135-
- <span class="signature">[`maxsorted( N, x, stride )`][@stdlib/stats/base/maxsorted]</span><span class="delimiter">: </span><span class="description">calculate the maximum value of a sorted strided array.</span>
133+
- <span class="signature">[`maxsorted( N, x, strideX )`][@stdlib/stats/base/maxsorted]</span><span class="delimiter">: </span><span class="description">calculate the maximum value of a sorted strided array.</span>
136134
- <span class="signature">[`mean( N, x, stride )`][@stdlib/stats/base/mean]</span><span class="delimiter">: </span><span class="description">calculate the arithmetic mean of a strided array.</span>
137135
- <span class="signature">[`meankbn( N, x, stride )`][@stdlib/stats/base/meankbn]</span><span class="delimiter">: </span><span class="description">calculate the arithmetic mean of a strided array using an improved Kahan–Babuška algorithm.</span>
138136
- <span class="signature">[`meankbn2( N, x, stride )`][@stdlib/stats/base/meankbn2]</span><span class="delimiter">: </span><span class="description">calculate the arithmetic mean of a strided array using a second-order iterative Kahan–Babuška algorithm.</span>
139137
- <span class="signature">[`meanors( N, x, stride )`][@stdlib/stats/base/meanors]</span><span class="delimiter">: </span><span class="description">calculate the arithmetic mean of a strided array using ordinary recursive summation.</span>
140138
- <span class="signature">[`meanpn( N, x, stride )`][@stdlib/stats/base/meanpn]</span><span class="delimiter">: </span><span class="description">calculate the arithmetic mean of a strided array using a two-pass error correction algorithm.</span>
141139
- <span class="signature">[`meanpw( N, x, stride )`][@stdlib/stats/base/meanpw]</span><span class="delimiter">: </span><span class="description">calculate the arithmetic mean of a strided array using pairwise summation.</span>
142140
- <span class="signature">[`meanwd( N, x, stride )`][@stdlib/stats/base/meanwd]</span><span class="delimiter">: </span><span class="description">calculate the arithmetic mean of a strided array using Welford's algorithm.</span>
143-
- <span class="signature">[`mediansorted( N, x, stride )`][@stdlib/stats/base/mediansorted]</span><span class="delimiter">: </span><span class="description">calculate the median value of a sorted strided array.</span>
141+
- <span class="signature">[`mediansorted( N, x, strideX )`][@stdlib/stats/base/mediansorted]</span><span class="delimiter">: </span><span class="description">calculate the median value of a sorted strided array.</span>
144142
- <span class="signature">[`minBy( N, x, stride, clbk[, thisArg] )`][@stdlib/stats/base/min-by]</span><span class="delimiter">: </span><span class="description">calculate the minimum value of a strided array via a callback function.</span>
145143
- <span class="signature">[`min( N, x, strideX )`][@stdlib/stats/base/min]</span><span class="delimiter">: </span><span class="description">calculate the minimum value of a strided array.</span>
146144
- <span class="signature">[`minabs( N, x, strideX )`][@stdlib/stats/base/minabs]</span><span class="delimiter">: </span><span class="description">calculate the minimum absolute value of a strided array.</span>
147-
- <span class="signature">[`minsorted( N, x, stride )`][@stdlib/stats/base/minsorted]</span><span class="delimiter">: </span><span class="description">calculate the minimum value of a sorted strided array.</span>
145+
- <span class="signature">[`minsorted( N, x, strideX )`][@stdlib/stats/base/minsorted]</span><span class="delimiter">: </span><span class="description">calculate the minimum value of a sorted strided array.</span>
148146
- <span class="signature">[`mskmax( N, x, strideX, mask, strideMask )`][@stdlib/stats/base/mskmax]</span><span class="delimiter">: </span><span class="description">calculate the maximum value of a strided array according to a mask.</span>
149147
- <span class="signature">[`mskmin( N, x, strideX, mask, strideMask )`][@stdlib/stats/base/mskmin]</span><span class="delimiter">: </span><span class="description">calculate the minimum value of a strided array according to a mask.</span>
150148
- <span class="signature">[`mskrange( N, x, strideX, mask, strideMask )`][@stdlib/stats/base/mskrange]</span><span class="delimiter">: </span><span class="description">calculate the range of a strided array according to a mask.</span>
@@ -333,10 +331,6 @@ console.log( objectKeys( ns ) );
333331

334332
[@stdlib/stats/base/dmskrange]: https://github.com/stdlib-js/stats/tree/main/base/dmskrange
335333

336-
[@stdlib/stats/strided/dnanmax]: https://github.com/stdlib-js/stats/tree/main/strided/dnanmax
337-
338-
[@stdlib/stats/strided/dnanmaxabs]: https://github.com/stdlib-js/stats/tree/main/strided/dnanmaxabs
339-
340334
[@stdlib/stats/base/dnanmean]: https://github.com/stdlib-js/stats/tree/main/base/dnanmean
341335

342336
[@stdlib/stats/base/dnanmeanors]: https://github.com/stdlib-js/stats/tree/main/base/dnanmeanors

base/dists/bradford/cdf/README.md

+157
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
<!--
2+
3+
@license Apache-2.0
4+
5+
Copyright (c) 2025 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+
> [Bradford][bradford-distribution] distribution [cumulative distribution function][cdf] (CDF).
24+
25+
<section class="intro">
26+
27+
The [cumulative distribution function][cdf] (CDF) for a [Bradford][bradford-distribution] random variable is
28+
29+
<!-- <equation class="equation" label="eq:bradford_cdf" align="center" raw="F(x;c)=\frac{\ln(1+cx)}{\ln(1+c)}" alt="Cumulative distribution function (CDF) for a Bradford distribution."> -->
30+
31+
```math
32+
F(x;c)=\frac{\ln(1+cx)}{\ln(1+c)}
33+
```
34+
35+
<!-- <div class="equation" align="center" data-raw-text="F(x;c)=\frac{\ln(1+cx)}{\ln(1+c)}" data-equation="eq:bradford_cdf">
36+
<img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@51534079fef45e990850102147e8945fb023d1d0/lib/node_modules/@stdlib/stats/base/dists/bradford/cdf/docs/img/equation_bradford_cdf.svg" alt="Cumulative distribution function (CDF) for a Bradford distribution.">
37+
<br>
38+
</div> -->
39+
40+
<!-- </equation> -->
41+
42+
where `c > 0` is the shape parameter of the distribution.
43+
44+
</section>
45+
46+
<!-- /.intro -->
47+
48+
<section class="usage">
49+
50+
## Usage
51+
52+
```javascript
53+
var cdf = require( '@stdlib/stats/base/dists/bradford/cdf' );
54+
```
55+
56+
#### cdf( x, c )
57+
58+
Evaluates the [cumulative distribution function][cdf] (CDF) for a [Bradford][bradford-distribution] distribution with shape parameter `c` at a value `x`.
59+
60+
```javascript
61+
var y = cdf( 0.1, 0.1 );
62+
// returns ~0.104
63+
64+
y = cdf( 0.5, 5.0 );
65+
// returns ~0.699
66+
67+
y = cdf( 1.0, 10.0 );
68+
// returns 1.0
69+
70+
y = cdf( -0.5, 1.0 );
71+
// returns 0.0
72+
73+
y = cdf( 2.0, 1.0 );
74+
// returns 1.0
75+
```
76+
77+
If provided `NaN` as any argument, the function returns `NaN`.
78+
79+
```javascript
80+
var y = cdf( NaN, 1.0 );
81+
// returns NaN
82+
83+
y = cdf( 0.0, NaN );
84+
// returns NaN
85+
```
86+
87+
If provided a shape parameter `c <= 0`, the function returns `NaN`.
88+
89+
```javascript
90+
var y = cdf( 0.0, 0.0 );
91+
// returns NaN
92+
93+
y = cdf( 0.5, -5.0 );
94+
// returns NaN
95+
```
96+
97+
#### cdf.factory( c )
98+
99+
Returns a function for evaluating the [CDF][cdf] of a [Bradford][bradford-distribution] distribution with shape parameter `c`.
100+
101+
```javascript
102+
var myPDF = cdf.factory( 5.0 );
103+
var y = myPDF( 0.5 );
104+
// returns ~0.699
105+
106+
y = myPDF( 1.0 );
107+
// returns 1.0
108+
```
109+
110+
</section>
111+
112+
<!-- /.usage -->
113+
114+
<section class="examples">
115+
116+
## Examples
117+
118+
<!-- eslint no-undef: "error" -->
119+
120+
```javascript
121+
var uniform = require( '@stdlib/random/array/uniform' );
122+
var cdf = require( '@stdlib/stats/base/dists/bradford/cdf' );
123+
124+
var x = uniform( 10, 0.0, 1.0 );
125+
var c = uniform( 10, 0.1, 10.0 );
126+
127+
var y;
128+
var i;
129+
for ( i = 0; i < x.length; i++ ) {
130+
y = cdf( x[ i ], c[ i ] );
131+
console.log( 'x: %d, c: %d, F(x;c): %d', x[ i ].toFixed( 4 ), c[ i ].toFixed( 4 ), y.toFixed( 4 ) );
132+
}
133+
```
134+
135+
</section>
136+
137+
<!-- /.examples -->
138+
139+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
140+
141+
<section class="related">
142+
143+
</section>
144+
145+
<!-- /.related -->
146+
147+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
148+
149+
<section class="links">
150+
151+
[cdf]: https://en.wikipedia.org/wiki/Cumulative_distribution_function
152+
153+
[bradford-distribution]: https://en.wikipedia.org/wiki/Bradford%27s_law
154+
155+
</section>
156+
157+
<!-- /.links -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var bench = require( '@stdlib/bench' );
24+
var uniform = require( '@stdlib/random/array/uniform' );
25+
var isnan = require( '@stdlib/math/base/assert/is-nan' );
26+
var pkg = require( './../package.json' ).name;
27+
var cdf = require( './../lib' );
28+
29+
30+
// MAIN //
31+
32+
bench( pkg, function benchmark( b ) {
33+
var x;
34+
var c;
35+
var y;
36+
var i;
37+
38+
x = uniform( 100, 0.0, 1.0 );
39+
c = uniform( 100, 0.1, 10.0 );
40+
41+
b.tic();
42+
for ( i = 0; i < b.iterations; i++ ) {
43+
y = cdf( x[ i % x.length ], c[ i % c.length ] );
44+
if ( isnan( y ) ) {
45+
b.fail( 'should not return NaN' );
46+
}
47+
}
48+
b.toc();
49+
if ( isnan( y ) ) {
50+
b.fail( 'should not return NaN' );
51+
}
52+
b.pass( 'benchmark finished' );
53+
b.end();
54+
});
55+
56+
bench( pkg+':factory', function benchmark( b ) {
57+
var mycdf;
58+
var x;
59+
var y;
60+
var i;
61+
62+
x = uniform( 100, 0.0, 1.0 );
63+
mycdf = cdf.factory( 5.0 );
64+
65+
b.tic();
66+
for ( i = 0; i < b.iterations; i++ ) {
67+
y = mycdf( x[ i % x.length ] );
68+
if ( isnan( y ) ) {
69+
b.fail( 'should not return NaN' );
70+
}
71+
}
72+
b.toc();
73+
if ( isnan( y ) ) {
74+
b.fail( 'should not return NaN' );
75+
}
76+
b.pass( 'benchmark finished' );
77+
b.end();
78+
});

0 commit comments

Comments
 (0)