Skip to content

Commit

Permalink
Auto-generated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Feb 8, 2025
1 parent b7807c5 commit e76b3e9
Show file tree
Hide file tree
Showing 20 changed files with 1,282 additions and 5 deletions.
1 change: 0 additions & 1 deletion .github/.keepalive

This file was deleted.

29 changes: 27 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,37 @@
<section class="release" id="unreleased">

## Unreleased (2025-02-03)
## Unreleased (2025-02-08)

<section class="features">

### Features

- [`f9789d4`](https://github.com/stdlib-js/stdlib/commit/f9789d46cf8f045048c416e7c420f96b1bb45141) - add C implementation for `stats/base/dists/degenerate/logcdf` [(#4387)](https://github.com/stdlib-js/stdlib/pull/4387)

</section>

<!-- /.features -->

<section class="issues">

### Closed Issues

This release closes the following issue:

[#3537](https://github.com/stdlib-js/stdlib/issues/3537)

</section>

<!-- /.issues -->

<section class="commits">

### Commits

<details>

- [`f9789d4`](https://github.com/stdlib-js/stdlib/commit/f9789d46cf8f045048c416e7c420f96b1bb45141) - **feat:** add C implementation for `stats/base/dists/degenerate/logcdf` [(#4387)](https://github.com/stdlib-js/stdlib/pull/4387) _(by Neeraj Pathak, Philipp Burckhardt, stdlib-bot)_
- [`1fc3918`](https://github.com/stdlib-js/stdlib/commit/1fc3918810a556d2593f4ec8a0764dce88a519fc) - **bench:** refactor random number generation in `stats/base/dists/degenerate` [(#4862)](https://github.com/stdlib-js/stdlib/pull/4862) _(by Karan Anand)_

</details>
Expand All @@ -24,9 +47,11 @@

### Contributors

A total of 1 person contributed to this release. Thank you to this contributor:
A total of 3 people contributed to this release. Thank you to the following contributors:

- Karan Anand
- Neeraj Pathak
- Philipp Burckhardt

</section>

Expand Down
2 changes: 2 additions & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Marcus Fantham <[email protected]>
Matt Cochrane <[email protected]>
Mihir Pandit <[email protected]>
Milan Raj <[email protected]>
Mohammad Bin Aftab <[email protected]>
Mohammad Kaif <[email protected]>
Momtchil Momtchev <[email protected]>
Muhammad Haris <[email protected]>
Expand Down Expand Up @@ -125,5 +126,6 @@ Xiaochuan Ye <[email protected]>
Yaswanth Kosuru <[email protected]>
Yernar Yergaziyev <[email protected]>
olenkabilonizhka <[email protected]>
pranav-1720 <[email protected]>
rainn <[email protected]>
rei2hu <[email protected]>
96 changes: 96 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,102 @@ for ( i = 0; i < 100; i++ ) {

<!-- /.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/degenerate/logcdf.h"
```

#### stdlib_base_dists_degenerate_logcdf( x, mu )

Evaluates the natural logarithm of the [CDF][cdf] of a [degenerate distribution][degenerate-distribution] centered at `mu`.

```c
double y = stdlib_base_dists_degenerate_logcdf( 2.0, 3.0 );
// returns -Infinity
```

The function accepts the following arguments:

- **x**: `[in] double` input value.
- **mu**: `[in] double` constant value of distribution.

```c
double stdlib_base_dists_degenerate_logcdf( const double x, const double mu );
```
</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/degenerate/logcdf.h"
#include "stdlib/math/base/special/round.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 mu;
double x;
double y;
int i;
for ( i = 0; i < 10; i++ ) {
x = stdlib_base_round( random_uniform( 0.0, 10.0 ) );
mu = stdlib_base_round( random_uniform( 0.0, 10.0 ) );
y = stdlib_base_dists_degenerate_logcdf( x, mu );
printf( "x: %lf, µ: %lf, ln(F(x;µ)): %lf\n", x, mu, y );
}
}
```

</section>

<!-- /.examples -->

</section>

<!-- /.c -->

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

<section class="related">
Expand Down
3 changes: 2 additions & 1 deletion benchmark/benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
// MODULES //

var bench = require( '@stdlib/bench-harness' );
var Float64Array = require( '@stdlib/array-float64' );
var uniform = require( '@stdlib/random-base-uniform' );
var Float64Array = require( '@stdlib/array-float64' );
var isnan = require( '@stdlib/math-base-assert-is-nan' );
var pkg = require( './../package.json' ).name;
var logcdf = require( './../lib' );
Expand Down Expand Up @@ -70,6 +70,7 @@ bench( pkg+':factory', function benchmark( b ) {

mu = 40.0;
mylogcdf = logcdf.factory( mu );

len = 100;
x = new Float64Array( len );
for ( i = 0; i < len; i++ ) {
Expand Down
71 changes: 71 additions & 0 deletions benchmark/benchmark.native.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@

/**
* @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 resolve = require( 'path' ).resolve;
var bench = require( '@stdlib/bench-harness' );
var uniform = require( '@stdlib/random-base-uniform' );
var Float64Array = require( '@stdlib/array-float64' );
var isnan = require( '@stdlib/math-base-assert-is-nan' );
var tryRequire = require( '@stdlib/utils-try-require' );
var pkg = require( './../package.json' ).name;


// VARIABLES //

var logcdf = tryRequire( resolve( __dirname, './../lib/native.js' ) );
var opts = {
'skip': ( logcdf instanceof Error )
};


// MAIN //

bench( pkg+'::native', opts, function benchmark( b ) {
var len;
var mu;
var x;
var y;
var i;

len = 100;
x = new Float64Array( len );
mu = new Float64Array( len );
for ( i = 0; i < len; i++ ) {
x[ i ] = uniform( -100.0, 0.0 );
mu[ i ] = uniform( -50.0, 50.0 );
}

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

0 comments on commit e76b3e9

Please sign in to comment.