Skip to content

Commit 9321c72

Browse files
committed
Auto-generated commit
1 parent 26c8e74 commit 9321c72

22 files changed

+1350
-9
lines changed

.editorconfig

-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ indent_style = tab
8686
[*.{f,f.txt}]
8787
indent_style = space
8888
indent_size = 2
89-
insert_final_newline = false
9089

9190
# Set properties for shell files:
9291
[*.{sh,sh.txt}]

.github/.keepalive

-1
This file was deleted.

CHANGELOG.md

+57
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 (2025-01-19)
8+
9+
<section class="features">
10+
11+
### Features
12+
13+
- [`1188836`](https://github.com/stdlib-js/stdlib/commit/118883606bab688a753219662cb78850e7a48237) - add C implementation for `stats/base/dists/cauchy/median` [(#3958)](https://github.com/stdlib-js/stdlib/pull/3958)
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+
[#3483](https://github.com/stdlib-js/stdlib/issues/3483)
26+
27+
</section>
28+
29+
<!-- /.issues -->
30+
31+
<section class="commits">
32+
33+
### Commits
34+
35+
<details>
36+
37+
- [`1188836`](https://github.com/stdlib-js/stdlib/commit/118883606bab688a753219662cb78850e7a48237) - **feat:** add C implementation for `stats/base/dists/cauchy/median` [(#3958)](https://github.com/stdlib-js/stdlib/pull/3958) _(by Vivek Maurya, Philipp Burckhardt, stdlib-bot)_
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+
- Philipp Burckhardt
52+
- Vivek Maurya
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-27)

CONTRIBUTORS

+4-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ Daniel Killenberger <[email protected]>
2727
Daniel Yu <[email protected]>
2828
Debashis Maharana <[email protected]>
2929
Desh Deepak Kant <[email protected]>
30+
31+
Dhruv Arvind Singh <[email protected]>
3032
Divyansh Seth <[email protected]>
3133
Dominic Lim <[email protected]>
3234
Dominik Moritz <[email protected]>
@@ -49,6 +51,7 @@ Joey Reed <[email protected]>
4951
Jordan Gallivan <[email protected]>
5052
Joris Labie <[email protected]>
5153
Justin Dennison <[email protected]>
54+
Karan Anand <[email protected]>
5255
Karthik Prakash <[email protected]>
5356
Kohantika Nath <[email protected]>
5457
Krishnendu Das <[email protected]>
@@ -117,7 +120,7 @@ UtkershBasnet <[email protected]>
117120
Vaibhav Patel <[email protected]>
118121
Varad Gupta <[email protected]>
119122
Vinit Pandit <[email protected]>
120-
Vivek maurya <[email protected].com>
123+
Vivek Maurya <vm8118134@gmail.com>
121124
Xiaochuan Ye <[email protected]>
122125
Yaswanth Kosuru <[email protected]>
123126
Yernar Yergaziyev <[email protected]>

NOTICE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Copyright (c) 2016-2024 The Stdlib Authors.
1+
Copyright (c) 2016-2025 The Stdlib Authors.

README.md

+97-1
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,102 @@ for ( i = 0; i < 10; i++ ) {
162162

163163
<!-- /.examples -->
164164

165+
<!-- C interface documentation. -->
166+
167+
* * *
168+
169+
<section class="c">
170+
171+
## C APIs
172+
173+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
174+
175+
<section class="intro">
176+
177+
</section>
178+
179+
<!-- /.intro -->
180+
181+
<!-- C usage documentation. -->
182+
183+
<section class="usage">
184+
185+
### Usage
186+
187+
```c
188+
#include "stdlib/stats/base/dists/cauchy/median.h"
189+
```
190+
191+
#### stdlib_base_dists_cauchy_median( x0, gamma )
192+
193+
Evaluates the [median][median] of a [Cauchy][cauchy-distribution] distribution with location parameter `x0` and scale parameter `gamma`.
194+
195+
```c
196+
double out = stdlib_base_dists_cauchy_median( 10.0, 5.0 );
197+
// returns 10.0
198+
```
199+
200+
The function accepts the following arguments:
201+
202+
- **x0**: `[in] double` location parameter.
203+
- **gamma**: `[in] double` scale parameter.
204+
205+
```c
206+
double stdlib_base_dists_cauchy_median( const double x0, const double gamma );
207+
```
208+
209+
</section>
210+
211+
<!-- /.usage -->
212+
213+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
214+
215+
<section class="notes">
216+
217+
</section>
218+
219+
<!-- /.notes -->
220+
221+
<!-- C API usage examples. -->
222+
223+
<section class="examples">
224+
225+
### Examples
226+
227+
```c
228+
#include "stdlib/stats/base/dists/cauchy/median.h"
229+
#include "stdlib/constants/float64/eps.h"
230+
#include <stdlib.h>
231+
#include <stdio.h>
232+
233+
static double random_uniform( const double min, const double max ) {
234+
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
235+
return min + ( v*(max-min) );
236+
}
237+
238+
int main( void ) {
239+
double gamma;
240+
double x0;
241+
double y;
242+
int i;
243+
244+
for ( i = 0; i < 25; i++ ) {
245+
x0 = random_uniform( 0.0, 100.0 );
246+
gamma = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 10.0 );
247+
y = stdlib_base_dists_cauchy_median( x0, gamma );
248+
printf( "x0: %lf, gamma: %lf, Median(x0;gamma): %lf\n", x0, gamma, y );
249+
}
250+
}
251+
```
252+
253+
</section>
254+
255+
<!-- /.examples -->
256+
257+
</section>
258+
259+
<!-- /.c -->
260+
165261
<!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
166262

167263
<section class="references">
@@ -204,7 +300,7 @@ See [LICENSE][stdlib-license].
204300

205301
## Copyright
206302

207-
Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
303+
Copyright &copy; 2016-2025. The Stdlib [Authors][stdlib-authors].
208304

209305
</section>
210306

benchmark/benchmark.js

+11-3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench-harness' );
24+
var Float64Array = require( '@stdlib/array-float64' );
2425
var randu = require( '@stdlib/random-base-randu' );
2526
var isnan = require( '@stdlib/math-base-assert-is-nan' );
2627
var EPS = require( '@stdlib/constants-float64-eps' );
@@ -32,15 +33,22 @@ var median = require( './../lib' );
3233

3334
bench( pkg, function benchmark( b ) {
3435
var gamma;
36+
var len;
3537
var x0;
3638
var y;
3739
var i;
3840

41+
len = 100;
42+
x0 = new Float64Array( len );
43+
gamma = new Float64Array( len );
44+
for ( i = 0; i < len; i++ ) {
45+
x0[ i ] = ( randu() * 100.0 ) - 50.0;
46+
gamma[ i ] = ( randu() * 20.0 ) + EPS;
47+
}
48+
3949
b.tic();
4050
for ( i = 0; i < b.iterations; i++ ) {
41-
x0 = ( randu()*100.0 ) - 50.0;
42-
gamma = ( randu()*20.0 ) + EPS;
43-
y = median( x0, gamma );
51+
y = median( x0[ i % len ], gamma[ i % len ] );
4452
if ( isnan( y ) ) {
4553
b.fail( 'should not return NaN' );
4654
}

benchmark/benchmark.native.js

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

0 commit comments

Comments
 (0)