Skip to content

feat: add stats/base/dists/burr-type3/cdf #5916

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 8 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
183 changes: 183 additions & 0 deletions lib/node_modules/@stdlib/stats/base/dists/burr-type3/cdf/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
<!--

@license Apache-2.0

Copyright (c) 2025 The Stdlib Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

-->

# Cumulative Distribution Function

> [Burr (type III)][burr-distribution] distribution [cumulative distribution function][cdf].

<section class="intro">

The [cumulative distribution function][cdf] for a [Burr (type III)][burr-distribution] random variable is

<!-- <equation class="equation" label="eq:burr-type3_cdf" align="center"
raw="F(x; c, d) = (1 + x^{-c})^{-d}"
alt="Cumulative distribution function for a Burr (Type III) distribution."> -->

```math
F(x; alpha, beta) = (1 + x^{-alpha})^{-beta}
```

<!-- <div class="equation" align="center" data-raw-text="F(x;c,d) = (1 + x^{-c})^{-d}" data-equation="eq:burr-type3_cdf">
<img src="https://quicklatex.com/cache3/1e/ql_96e6c56a3c01ce5db3f378b28ee9511e_l3.png" alt="Cumulative distribution function for a Burr (Type III) distribution.">
<br>
</div> -->
Comment on lines +37 to +40
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should remove this as it will be auto-generated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ook


<!-- </equation> -->

where `alpha > 0` is the first shape parameter and `beta > 0` is the second shape parameter.

</section>

<!-- /.intro -->

<section class="usage">

## Usage

```javascript
var cdf = require( '@stdlib/stats/base/dists/burr-type3/cdf' );
```

#### cdf( x, alpha, beta )

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).

```javascript
var y = cdf( 0.1, 1.0, 1.0 );
// returns ~0.09

y = cdf( 0.2, 2.0, 2.0 );
// returns ~0.0015

y = cdf( 0.4, 4.0, 4.0 );
// returns ~3.88e-7

y = cdf( 1.0, 0.1, 1.0 );
// returns 0.5

y = cdf( 0.3, 0.5, 0.5 );
// returns ~0.59

y = cdf( 0.5, 1.0, 1.0 );
// returns ~0.33

y = cdf( 0.5, 2.0, 4.0 );
// returns ~0.0016

y = cdf( 0.8, 0.5, 0.5 );
// returns ~0.69
```

If provided `NaN` as any argument, the function returns `NaN`.

```javascript
var y = cdf( NaN, 1.0, 1.0 );
// returns NaN

y = cdf( 0.0, NaN, 1.0 );
// returns NaN

y = cdf( 0.0, 1.0, NaN );
// returns NaN
```

If provided `alpha <= 0`, the function returns `NaN`.

```javascript
var y = cdf( 2.0, -1.0, 0.5 );
// returns NaN

y = cdf( 2.0, 0.0, 0.5 );
// returns NaN
```

If provided `beta <= 0`, the function returns `NaN`.

```javascript
var y = cdf( 2.0, 0.5, -1.0 );
// returns NaN

y = cdf( 2.0, 0.5, 0.0 );
// returns NaN
```

#### cdf.factory( alpha, beta )

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).

```javascript
var mycdf = cdf.factory( 0.5, 0.5 );

var y = mycdf( 0.8 );
// returns ~0.69

y = mycdf( 0.3 );
// returns ~0.59
```

</section>

<!-- /.usage -->

<section class="examples">

## Examples

<!-- eslint no-undef: "error" -->

```javascript
var cdf = require( '@stdlib/stats/base/dists/burr-type3/cdf' );
var linspace = require( '@stdlib/array/linspace' );

var alpha = linspace( 1, 10.0, 10 );
var beta = linspace( 1, 10.0, 10 );
var x = linspace( 0.1, 1.0, 10 );
var y;
var i;

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

</section>

<!-- /.examples -->

<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->

<section class="related">

</section>

<!-- /.related -->

<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="links">

[burr-distribution]: https://en.wikipedia.org/wiki/Burr_distribution

[cdf]: https://en.wikipedia.org/wiki/Cumulative_distribution_function

</section>

<!-- /.links -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2025 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

// MODULES //

var bench = require( '@stdlib/bench' );
var uniform = require( '@stdlib/random/array/uniform' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var pkg = require( './../package.json' ).name;
var cdf = require( './../lib' );


// MAIN //

bench( pkg, function benchmark( b ) {
var alpha;
var beta;
var len;
var x;
var y;
var i;

len = 100;
x = uniform( len, 0.0, 10.0 );
alpha = uniform( len, 0.1, 100.0 );
beta = uniform( len, 0.1, 100.0 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
y = cdf( x[ i % len ], alpha[ i % len ], beta[ i % len ] );
if ( isnan( y ) ) {
b.fail( 'should not return NaN' );
}
}
b.toc();
if ( isnan( y ) ) {
b.fail( 'should not return NaN' );
}
b.pass( 'benchmark finished' );
b.end();
});

bench( pkg+':factory', function benchmark( b ) {
var mycdf;
var len;
var x;
var y;
var i;

len = 100;
x = uniform( len, 0.0, 10.0 );
mycdf = cdf.factory( 5.0, 6.0 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
y = mycdf( x[ i % len ] );
if ( isnan( y ) ) {
b.fail( 'should not return NaN' );
}
}
b.toc();
if ( isnan( y ) ) {
b.fail( 'should not return NaN' );
}
b.pass( 'benchmark finished' );
b.end();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#!/usr/bin/env python
#
# @license Apache-2.0
#
# Copyright (c) 2025 The Stdlib Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Benchmark scipy.stats.burr.cdf."""

from __future__ import print_function
import timeit

NAME = "burr:cdf"
REPEATS = 3
ITERATIONS = 1000


def print_version():
"""Print the TAP version."""
print("TAP version 13")


def print_summary(total, passing):
"""Print the benchmark summary.

# Arguments

* `total`: total number of tests
* `passing`: number of passing tests

"""
print("#")
print("1.." + str(total)) # TAP plan
print("# total " + str(total))
print("# pass " + str(passing))
print("#")
print("# ok")


def print_results(elapsed):
"""Print benchmark results.

# Arguments

* `elapsed`: elapsed time (in seconds)

# Examples

``` python
python> print_results(0.131009101868)
```
"""
rate = ITERATIONS / elapsed

print(" ---")
print(" iterations: " + str(ITERATIONS))
print(" elapsed: " + str(elapsed))
print(" rate: " + str(rate))
print(" ...")


def benchmark():
"""Run the benchmark and print benchmark results."""
setup = "from scipy.stats import burr; from random import random;"
stmt = "y = burr.cdf(random(), 100.56789, 55.54321)"

t = timeit.Timer(stmt, setup=setup)

print_version()

for i in range(REPEATS):
print("# python::" + NAME)
elapsed = t.timeit(number=ITERATIONS)
print_results(elapsed)
print("ok " + str(i+1) + " benchmark finished")

print_summary(REPEATS, REPEATS)


def main():
"""Run the benchmark."""
benchmark()


if __name__ == "__main__":
main()
Loading
Loading