Skip to content
Merged
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
283 changes: 283 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,283 @@
<!--

@license Apache-2.0

Copyright (c) 2026 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; c, d) = (1 + x^{-c})^{-d}
```

<!-- </equation> -->

where `c > 0` is the first shape parameter and `d > 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, c, d )

Evaluates the [cumulative distribution function][cdf] (CDF) for a [Burr (type III)][burr-distribution] distribution with parameters `c` (first shape parameter) and `d` (second shape parameter).

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

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

y = cdf( 0.3, 2.0, 2.0 );
// returns ~0.007

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

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

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

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

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

If provided `x <= 0`, the function returns `0`.

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

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

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 `c <= 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 `d <= 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( c, d )

Returns a function for evaluating the [cumulative distribution function][cdf] for a [Burr (type III)][burr-distribution] distribution with parameters `c` (first shape parameter) and `d` (second shape parameter).

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

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

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

</section>

<!-- /.usage -->

<section class="examples">

## Examples

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

```javascript
var uniform = require( '@stdlib/random/array/uniform' );
var logEachMap = require( '@stdlib/console/log-each-map' );
var cdf = require( '@stdlib/stats/base/dists/burr-type3/cdf' );

var opts = {
'dtype': 'float64'
};
var x = uniform( 10, 0.1, 1.0, opts );
var c = uniform( 10, 1.0, 10.0, opts );
var d = uniform( 10, 1.0, 10.0, opts );

logEachMap( 'x: %0.4f, c: %0.4f, d: %0.4f, F(x;c,d): %0.4f', x, c, d, cdf );
```

</section>

<!-- /.examples -->

<!-- C interface documentation. -->

* * *

<section class="c">

## C APIs

<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->

<section class="intro">

</section>

<!-- /.intro -->

<!-- C usage documentation. -->

<section class="usage">

### Usage

```c
#include "stdlib/stats/base/dists/burr-type3/cdf.h"
```

#### stdlib_base_dists_burr_type3_cdf( x, c, d )

Evaluates the cumulative distribution function (CDF) for a Burr (type III) distribution with first shape parameter `c` and second shape parameter `d` at input value `x`.

```c
double y = stdlib_base_dists_burr_type3_cdf( 0.1, 1.0, 1.0 );
// returns ~0.091
```

The function accepts the following arguments:

- **x**: `[in] double` input value.
- **c**: `[in] double` first shape parameter.
- **d**: `[in] double` second shape parameter.

```c
double stdlib_base_dists_burr_type3_cdf( const double x, const double c, const double d );
```

</section>

<!-- /.usage -->

<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="notes">

</section>

<!-- /.notes -->

<!-- C API usage examples. -->

<section class="examples">

### Examples

```c
#include "stdlib/stats/base/dists/burr-type3/cdf.h"
#include <stdlib.h>
#include <stdio.h>

static double random_uniform( const double min, const double max ) {
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
return min + ( v*(max-min) );
}

int main( void ) {
double x;
double c;
double d;
double y;
int i;

for ( i = 0; i < 10; i++ ) {
x = random_uniform( 0.1, 1.0 );
c = random_uniform( 1.0, 10.0 );
d = random_uniform( 1.0, 10.0 );
y = stdlib_base_dists_burr_type3_cdf( x, c, d );
printf( "x: %lf, c: %lf, d: %lf, F(x;c,d): %lf\n", x, c, d, y );
}
}
```

</section>

<!-- /.examples -->

</section>

<!-- /.c -->

<!-- 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,89 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2026 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 format = require( '@stdlib/string/format' );
var pkg = require( './../package.json' ).name;
var cdf = require( './../lib' );


// MAIN //

bench( pkg, function benchmark( b ) {
var opts;
var c;
var d;
var x;
var y;
var i;

opts = {
'dtype': 'float64'
};
x = uniform( 100, 0.0, 10.0, opts );
c = uniform( 100, 0.1, 100.0, opts );
d = uniform( 100, 0.1, 100.0, opts );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
y = cdf( x[ i % x.length ], c[ i % c.length ], d[ i % d.length ] );
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( format( '%s::factory', pkg ), function benchmark( b ) {
var mycdf;
var opts;
var x;
var y;
var i;

opts = {
'dtype': 'float64'
};
x = uniform( 100, 0.0, 10.0, opts );
mycdf = cdf.factory( 5.0, 6.0 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
y = mycdf( x[ i % x.length ] );
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();
});
Loading