Skip to content

Commit 7a419a5

Browse files
committed
Auto-generated commit
1 parent 9e3435d commit 7a419a5

File tree

18 files changed

+1430
-13
lines changed

18 files changed

+1430
-13
lines changed

CHANGELOG.md

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,40 @@ This release closes the following issue:
762762

763763
<!-- /.package -->
764764

765+
<section class="package" id="stats-base-dists-t-logpdf-unreleased">
766+
767+
#### [@stdlib/stats/base/dists/t/logpdf](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/dists/t/logpdf)
768+
769+
<details>
770+
771+
<section class="features">
772+
773+
##### Features
774+
775+
- [`ad7c388`](https://github.com/stdlib-js/stdlib/commit/ad7c3880af37bccd159b6623f92d4b0212eaf0db) - add C implementation for `stats/base/dists/t/logpdf` [(#3934)](https://github.com/stdlib-js/stdlib/pull/3934)
776+
777+
</section>
778+
779+
<!-- /.features -->
780+
781+
<section class="issues">
782+
783+
##### Closed Issues
784+
785+
This release closes the following issue:
786+
787+
[#3873](https://github.com/stdlib-js/stdlib/issues/3873)
788+
789+
</section>
790+
791+
<!-- /.issues -->
792+
793+
</details>
794+
795+
</section>
796+
797+
<!-- /.package -->
798+
765799
<section class="package" id="stats-base-dists-t-mean-unreleased">
766800

767801
#### [@stdlib/stats/base/dists/t/mean](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/dists/t/mean)
@@ -944,9 +978,9 @@ A total of 3 issues were closed in this release:
944978

945979
### Closed Issues
946980

947-
A total of 29 issues were closed in this release:
981+
A total of 30 issues were closed in this release:
948982

949-
[#1619](https://github.com/stdlib-js/stdlib/issues/1619), [#1632](https://github.com/stdlib-js/stdlib/issues/1632), [#1633](https://github.com/stdlib-js/stdlib/issues/1633), [#3236](https://github.com/stdlib-js/stdlib/issues/3236), [#3237](https://github.com/stdlib-js/stdlib/issues/3237), [#3238](https://github.com/stdlib-js/stdlib/issues/3238), [#3378](https://github.com/stdlib-js/stdlib/issues/3378), [#3384](https://github.com/stdlib-js/stdlib/issues/3384), [#3385](https://github.com/stdlib-js/stdlib/issues/3385), [#3401](https://github.com/stdlib-js/stdlib/issues/3401), [#3402](https://github.com/stdlib-js/stdlib/issues/3402), [#3414](https://github.com/stdlib-js/stdlib/issues/3414), [#3417](https://github.com/stdlib-js/stdlib/issues/3417), [#3421](https://github.com/stdlib-js/stdlib/issues/3421), [#3431](https://github.com/stdlib-js/stdlib/issues/3431), [#3434](https://github.com/stdlib-js/stdlib/issues/3434), [#3435](https://github.com/stdlib-js/stdlib/issues/3435), [#3436](https://github.com/stdlib-js/stdlib/issues/3436), [#3438](https://github.com/stdlib-js/stdlib/issues/3438), [#3445](https://github.com/stdlib-js/stdlib/issues/3445), [#3446](https://github.com/stdlib-js/stdlib/issues/3446), [#3447](https://github.com/stdlib-js/stdlib/issues/3447), [#3671](https://github.com/stdlib-js/stdlib/issues/3671), [#3797](https://github.com/stdlib-js/stdlib/issues/3797), [#3798](https://github.com/stdlib-js/stdlib/issues/3798), [#3865](https://github.com/stdlib-js/stdlib/issues/3865), [#3874](https://github.com/stdlib-js/stdlib/issues/3874), [#3879](https://github.com/stdlib-js/stdlib/issues/3879), [#3880](https://github.com/stdlib-js/stdlib/issues/3880)
983+
[#1619](https://github.com/stdlib-js/stdlib/issues/1619), [#1632](https://github.com/stdlib-js/stdlib/issues/1632), [#1633](https://github.com/stdlib-js/stdlib/issues/1633), [#3236](https://github.com/stdlib-js/stdlib/issues/3236), [#3237](https://github.com/stdlib-js/stdlib/issues/3237), [#3238](https://github.com/stdlib-js/stdlib/issues/3238), [#3378](https://github.com/stdlib-js/stdlib/issues/3378), [#3384](https://github.com/stdlib-js/stdlib/issues/3384), [#3385](https://github.com/stdlib-js/stdlib/issues/3385), [#3401](https://github.com/stdlib-js/stdlib/issues/3401), [#3402](https://github.com/stdlib-js/stdlib/issues/3402), [#3414](https://github.com/stdlib-js/stdlib/issues/3414), [#3417](https://github.com/stdlib-js/stdlib/issues/3417), [#3421](https://github.com/stdlib-js/stdlib/issues/3421), [#3431](https://github.com/stdlib-js/stdlib/issues/3431), [#3434](https://github.com/stdlib-js/stdlib/issues/3434), [#3435](https://github.com/stdlib-js/stdlib/issues/3435), [#3436](https://github.com/stdlib-js/stdlib/issues/3436), [#3438](https://github.com/stdlib-js/stdlib/issues/3438), [#3445](https://github.com/stdlib-js/stdlib/issues/3445), [#3446](https://github.com/stdlib-js/stdlib/issues/3446), [#3447](https://github.com/stdlib-js/stdlib/issues/3447), [#3671](https://github.com/stdlib-js/stdlib/issues/3671), [#3797](https://github.com/stdlib-js/stdlib/issues/3797), [#3798](https://github.com/stdlib-js/stdlib/issues/3798), [#3865](https://github.com/stdlib-js/stdlib/issues/3865), [#3873](https://github.com/stdlib-js/stdlib/issues/3873), [#3874](https://github.com/stdlib-js/stdlib/issues/3874), [#3879](https://github.com/stdlib-js/stdlib/issues/3879), [#3880](https://github.com/stdlib-js/stdlib/issues/3880)
950984

951985
</section>
952986

@@ -981,6 +1015,7 @@ A total of 12 people contributed to this release. Thank you to the following con
9811015

9821016
<details>
9831017

1018+
- [`ad7c388`](https://github.com/stdlib-js/stdlib/commit/ad7c3880af37bccd159b6623f92d4b0212eaf0db) - **feat:** add C implementation for `stats/base/dists/t/logpdf` [(#3934)](https://github.com/stdlib-js/stdlib/pull/3934) _(by Aadish Jain, Philipp Burckhardt)_
9841019
- [`d7f5b56`](https://github.com/stdlib-js/stdlib/commit/d7f5b56fc072abf167bd5eb5e2163833715f2211) - **feat:** add C implementation of `stats/base/dists/rayleigh/cdf` [(#3931)](https://github.com/stdlib-js/stdlib/pull/3931) _(by Vinit Pandit, Philipp Burckhardt)_
9851020
- [`bb09b18`](https://github.com/stdlib-js/stdlib/commit/bb09b185f74d2fc05254a2f164119ca05054887f) - **feat:** add C implementation for `stats/base/dists/beta/variance` [(#3919)](https://github.com/stdlib-js/stdlib/pull/3919) _(by Vivek maurya, Philipp Burckhardt)_
9861021
- [`0e2d82a`](https://github.com/stdlib-js/stdlib/commit/0e2d82a0e55b279370365e56b765922321a69e05) - **feat:** add C implementation for `stats/base/dists/poisson/variance` [(#3933)](https://github.com/stdlib-js/stdlib/pull/3933) _(by Aayush Khanna, Philipp Burckhardt, stdlib-bot)_

base/dists/t/logpdf/README.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,101 @@ for ( i = 0; i < 10; i++ ) {
142142

143143
<!-- /.examples -->
144144

145+
<!-- C interface documentation. -->
146+
147+
* * *
148+
149+
<section class="c">
150+
151+
## C APIs
152+
153+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
154+
155+
<section class="intro">
156+
157+
</section>
158+
159+
<!-- /.intro -->
160+
161+
<!-- C usage documentation. -->
162+
163+
<section class="usage">
164+
165+
### Usage
166+
167+
```c
168+
#include "stdlib/stats/base/dists/t/logpdf.h"
169+
```
170+
171+
#### stdlib_base_dists_t_logpdf( x, a, b )
172+
173+
Evaluates the natural logarithm of the [PDF][pdf] for a [Student's t][t-distribution] distribution with degree of freedom `v`.
174+
175+
```c
176+
double out = stdlib_base_dists_t_logpdf( 0.5, 1.0 );
177+
// returns ~-1.368
178+
```
179+
180+
The function accepts the following arguments:
181+
182+
- **x**: `[in] double` input value.
183+
- **v**: `[in] double` degrees of freedom.
184+
185+
```c
186+
double stdlib_base_dists_t_logpdf( const double x, const double v );
187+
```
188+
189+
</section>
190+
191+
<!-- /.usage -->
192+
193+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
194+
195+
<section class="notes">
196+
197+
</section>
198+
199+
<!-- /.notes -->
200+
201+
<!-- C API usage examples. -->
202+
203+
<section class="examples">
204+
205+
### Examples
206+
207+
```c
208+
#include "stdlib/stats/base/dists/t/logpdf.h"
209+
#include <stdlib.h>
210+
#include <stdio.h>
211+
212+
static double random_uniform( const double min, const double max ) {
213+
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
214+
return min + ( v*(max-min) );
215+
}
216+
217+
int main( void ) {
218+
double x;
219+
double v;
220+
double y;
221+
int i;
222+
223+
for ( i = 0; i < 25; i++ ) {
224+
x = random_uniform( -10.0, 10.0 );
225+
v = random_uniform( 1.0, 100.0 );
226+
y = stdlib_base_dists_t_logpdf( x, v );
227+
printf( "x: %lf, v: %lf, logPDF(x;v): %lf\n", x, v, y );
228+
}
229+
}
230+
```
231+
232+
</section>
233+
234+
<!-- /.examples -->
235+
236+
</section>
237+
238+
<!-- /.c -->
239+
145240
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
146241

147242
<section class="related">

base/dists/t/logpdf/benchmark/benchmark.js

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench' );
24-
var ceil = require( '@stdlib/math/base/special/ceil' );
24+
var Float64Array = require( '@stdlib/array/float64' );
25+
var uniform = require( '@stdlib/random/array/uniform' );
2526
var randu = require( '@stdlib/random/base/randu' );
2627
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2728
var pkg = require( './../package.json' ).name;
@@ -31,16 +32,23 @@ var logpdf = require( './../lib' );
3132
// MAIN //
3233

3334
bench( pkg, function benchmark( b ) {
34-
var v;
35+
var len;
3536
var x;
37+
var v;
3638
var y;
3739
var i;
3840

41+
len = 100;
42+
x = new Float64Array( len );
43+
v = new Float64Array( len );
44+
for ( i = 0; i < len; i++ ) {
45+
x[ i ] = ( randu() * 20.0 ) - 10.0;
46+
v[ i ] = ( randu() * 100.0 ) + 1.0; // degrees of freedom > 0
47+
}
48+
3949
b.tic();
4050
for ( i = 0; i < b.iterations; i++ ) {
41-
x = ( randu()*100.0 ) - 100;
42-
v = ceil( randu()*100.0 );
43-
y = logpdf( x, v );
51+
y = logpdf( x[ i % len ], v[ i % len ] );
4452
if ( isnan( y ) ) {
4553
b.fail( 'should not return NaN' );
4654
}
@@ -53,20 +61,20 @@ bench( pkg, function benchmark( b ) {
5361
b.end();
5462
});
5563

56-
bench( pkg+':factory', function benchmark( b ) {
57-
var mypdf;
64+
bench( pkg + ':factory', function benchmark( b ) {
65+
var mylogpdf;
5866
var v;
5967
var x;
6068
var y;
6169
var i;
6270

63-
v = 3.0;
64-
mypdf = logpdf.factory( v );
71+
v = 10.0;
72+
mylogpdf = logpdf.factory( v );
73+
x = uniform( 100, -2.0, 2.0 );
6574

6675
b.tic();
6776
for ( i = 0; i < b.iterations; i++ ) {
68-
x = ( randu()*100.0 ) - 50.0;
69-
y = mypdf( x );
77+
y = mylogpdf( x[ i % x.length ] );
7078
if ( isnan( y ) ) {
7179
b.fail( 'should not return NaN' );
7280
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2024 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 resolve = require( 'path' ).resolve;
24+
var bench = require( '@stdlib/bench' );
25+
var Float64Array = require( '@stdlib/array/float64' );
26+
var randu = require( '@stdlib/random/base/randu' );
27+
var isnan = require( '@stdlib/math/base/assert/is-nan' );
28+
var tryRequire = require( '@stdlib/utils/try-require' );
29+
var pkg = require( './../package.json' ).name;
30+
31+
32+
// VARIABLES //
33+
34+
var logpdf = tryRequire( resolve( __dirname, './../lib/native.js' ) );
35+
var opts = {
36+
'skip': ( logpdf instanceof Error )
37+
};
38+
39+
40+
// MAIN //
41+
42+
bench( pkg + '::native', opts, function benchmark( b ) {
43+
var len;
44+
var x;
45+
var v;
46+
var y;
47+
var i;
48+
49+
len = 100;
50+
x = new Float64Array( len );
51+
v = new Float64Array( len );
52+
for ( i = 0; i < len; i++ ) {
53+
x[ i ] = ( randu() * 20.0 ) - 10.0;
54+
v[ i ] = ( randu() * 100.0 ) + 1.0; // degrees of freedom > 0
55+
}
56+
57+
b.tic();
58+
for ( i = 0; i < b.iterations; i++ ) {
59+
y = logpdf( x[ i % len ], v[ i % len ] );
60+
if ( isnan( y ) ) {
61+
b.fail( 'should not return NaN' );
62+
}
63+
}
64+
b.toc();
65+
if ( isnan( y ) ) {
66+
b.fail( 'should not return NaN' );
67+
}
68+
b.pass( 'benchmark finished' );
69+
b.end();
70+
});

0 commit comments

Comments
 (0)