Skip to content

Commit aad92ac

Browse files
committed
Auto-generated commit
1 parent d6886e5 commit aad92ac

File tree

20 files changed

+1476
-30
lines changed

20 files changed

+1476
-30
lines changed

.github/.keepalive

Lines changed: 0 additions & 1 deletion
This file was deleted.

CHANGELOG.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,63 @@
22

33
> Package changelog.
44
5+
<section class="release" id="unreleased">
6+
7+
## Unreleased (2024-12-16)
8+
9+
<section class="features">
10+
11+
### Features
12+
13+
- [`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)
14+
15+
</section>
16+
17+
<!-- /.features -->
18+
19+
<section class="issues">
20+
21+
### Closed Issues
22+
23+
This release closes the following issue:
24+
25+
[#3873](https://github.com/stdlib-js/stdlib/issues/3873)
26+
27+
</section>
28+
29+
<!-- /.issues -->
30+
31+
<section class="commits">
32+
33+
### Commits
34+
35+
<details>
36+
37+
- [`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)_
38+
39+
</details>
40+
41+
</section>
42+
43+
<!-- /.commits -->
44+
45+
<section class="contributors">
46+
47+
### Contributors
48+
49+
A total of 2 people contributed to this release. Thank you to the following contributors:
50+
51+
- Aadish Jain
52+
- Philipp Burckhardt
53+
54+
</section>
55+
56+
<!-- /.contributors -->
57+
58+
</section>
59+
60+
<!-- /.release -->
61+
562
<section class="release" id="v0.2.2">
663

764
## 0.2.2 (2024-07-28)

CONTRIBUTORS

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22
#
33
# Contributors listed in alphabetical order.
44

5+
Aadish Jain <[email protected]>
56
Aayush Khanna <[email protected]>
67
Abhijit Raut <[email protected]>
78
Adarsh Palaskar <[email protected]>
89
Aditya Sapra <[email protected]>
9-
AgPriyanshu18 <[email protected]>
10+
Ahmed Atwa <[email protected]>
11+
Ahmed Kashkoush <[email protected]>
12+
Ahmed Khaled <[email protected]>
1013
Aleksandr <[email protected]>
1114
Ali Salesi <[email protected]>
1215
Aman Bhansali <[email protected]>
@@ -45,12 +48,12 @@ Jordan Gallivan <[email protected]>
4548
Joris Labie <[email protected]>
4649
Justin Dennison <[email protected]>
4750
Karthik Prakash <[email protected]>
48-
4951
Kohantika Nath <[email protected]>
5052
Krishnendu Das <[email protected]>
5153
Kshitij-Dale <[email protected]>
52-
54+
Lovelin Dhoni J B <[email protected]>
5355
Manik Sharma <[email protected]>
56+
Manvith M <[email protected]>
5457
Marcus Fantham <[email protected]>
5558
Matt Cochrane <[email protected]>
5659
Mihir Pandit <[email protected]>
@@ -59,37 +62,40 @@ Mohammad Kaif <[email protected]>
5962
Momtchil Momtchev <[email protected]>
6063
Muhammad Haris <[email protected]>
6164
Naresh Jagadeesan <[email protected]>
65+
Naveen Kumar <[email protected]>
6266
Neeraj Pathak <[email protected]>
63-
NightKnight <Ahmedatwa866@yahoo.com>
67+
Nishant Shinde <[email protected].com>
6468
Nithin Katta <[email protected]>
6569
Nourhan Hasan <[email protected]>
6670
Ognjen Jevremović <[email protected]>
6771
Oneday12323 <[email protected]>
72+
Ori Miles <[email protected]>
6873
Philipp Burckhardt <[email protected]>
6974
Prajwal Kulkarni <[email protected]>
7075
Pranav Goswami <[email protected]>
71-
72-
76+
Pranjal Jha <[email protected]>
77+
Pratik Singh <[email protected]>
7378
Pratyush Kumar Chouhan <[email protected]>
74-
79+
Priyansh Prajapati <[email protected]>
80+
Priyanshu Agarwal <[email protected]>
7581
Pushpendra Chandravanshi <[email protected]>
76-
7782
Raunak Kumar Gupta <[email protected]>
7883
Rejoan Sardar <[email protected]>
7984
Ricky Reusser <[email protected]>
8085
Ridam Garg <[email protected]>
86+
8187
Robert Gislason <[email protected]>
8288
Roman Stetsyk <[email protected]>
83-
89+
Rutam Kathale <[email protected]>
8490
Ruthwik Chikoti <[email protected]>
8591
Ryan Seal <[email protected]>
8692
Rylan Yang <[email protected]>
8793
Sai Srikar Dumpeti <[email protected]>
88-
SarthakPaandey <[email protected]>
94+
Sarthak Paandey <[email protected]>
8995
Saurabh Singh <[email protected]>
9096
Seyyed Parsa Neshaei <[email protected]>
9197
Shashank Shekhar Singh <[email protected]>
92-
98+
Shivam Ahir <[email protected]>
9399
Shraddheya Shendre <[email protected]>
94100
Shubh Mehta <[email protected]>
95101
Shubham Mishra <[email protected]>
@@ -98,7 +104,7 @@ Snehil Shah <[email protected]>
98104
Soumajit Chatterjee <[email protected]>
99105
Spandan Barve <[email protected]>
100106
Stephannie Jiménez Gacha <[email protected]>
101-
Suraj kumar <[email protected]>
107+
Suraj Kumar <[email protected]>
102108
Tirtadwipa Manunggal <[email protected]>
103109
Tudor Pagu <[email protected]>
104110
Tufailahmed Bargir <[email protected]>
@@ -108,12 +114,10 @@ UtkershBasnet <[email protected]>
108114
Vaibhav Patel <[email protected]>
109115
Varad Gupta <[email protected]>
110116
Vinit Pandit <[email protected]>
117+
Vivek maurya <[email protected]>
111118
Xiaochuan Ye <[email protected]>
119+
Yaswanth Kosuru <[email protected]>
112120
Yernar Yergaziyev <[email protected]>
113-
114-
nishant-s7 <[email protected]>
115121
olenkabilonizhka <[email protected]>
116-
orimiles5 <[email protected]>
117122
118123
119-

README.md

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

176176
<!-- /.examples -->
177177

178+
<!-- C interface documentation. -->
179+
180+
* * *
181+
182+
<section class="c">
183+
184+
## C APIs
185+
186+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
187+
188+
<section class="intro">
189+
190+
</section>
191+
192+
<!-- /.intro -->
193+
194+
<!-- C usage documentation. -->
195+
196+
<section class="usage">
197+
198+
### Usage
199+
200+
```c
201+
#include "stdlib/stats/base/dists/t/logpdf.h"
202+
```
203+
204+
#### stdlib_base_dists_t_logpdf( x, a, b )
205+
206+
Evaluates the natural logarithm of the [PDF][pdf] for a [Student's t][t-distribution] distribution with degree of freedom `v`.
207+
208+
```c
209+
double out = stdlib_base_dists_t_logpdf( 0.5, 1.0 );
210+
// returns ~-1.368
211+
```
212+
213+
The function accepts the following arguments:
214+
215+
- **x**: `[in] double` input value.
216+
- **v**: `[in] double` degrees of freedom.
217+
218+
```c
219+
double stdlib_base_dists_t_logpdf( const double x, const double v );
220+
```
221+
222+
</section>
223+
224+
<!-- /.usage -->
225+
226+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
227+
228+
<section class="notes">
229+
230+
</section>
231+
232+
<!-- /.notes -->
233+
234+
<!-- C API usage examples. -->
235+
236+
<section class="examples">
237+
238+
### Examples
239+
240+
```c
241+
#include "stdlib/stats/base/dists/t/logpdf.h"
242+
#include <stdlib.h>
243+
#include <stdio.h>
244+
245+
static double random_uniform( const double min, const double max ) {
246+
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
247+
return min + ( v*(max-min) );
248+
}
249+
250+
int main( void ) {
251+
double x;
252+
double v;
253+
double y;
254+
int i;
255+
256+
for ( i = 0; i < 25; i++ ) {
257+
x = random_uniform( -10.0, 10.0 );
258+
v = random_uniform( 1.0, 100.0 );
259+
y = stdlib_base_dists_t_logpdf( x, v );
260+
printf( "x: %lf, v: %lf, logPDF(x;v): %lf\n", x, v, y );
261+
}
262+
}
263+
```
264+
265+
</section>
266+
267+
<!-- /.examples -->
268+
269+
</section>
270+
271+
<!-- /.c -->
272+
178273
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
179274

180275
<section class="related">

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-harness' );
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
}

0 commit comments

Comments
 (0)