Skip to content

Commit 6323126

Browse files
committed
Merge branch 'develop' of https://github.com/stdlib-js/stdlib into develop
2 parents a2339e3 + b822409 commit 6323126

File tree

19 files changed

+1380
-22
lines changed

19 files changed

+1380
-22
lines changed

lib/node_modules/@stdlib/number/float64/base/ulp-difference/lib/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ function ulpdiff( x, y ) {
183183
wx = toWords( x, WX, 1, 0 );
184184
wy = toWords( y, WY, 1, 0 );
185185

186-
// Convert the values to lexicographically order integers:
186+
// Convert the values to lexicographically ordered integers:
187187
wx = monotoneKey( wx );
188188
wy = monotoneKey( wy );
189189

lib/node_modules/@stdlib/stats/base/dists/kumaraswamy/quantile/README.md

Lines changed: 108 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ y = myQuantile( 0.3 );
139139
<!-- eslint no-undef: "error" -->
140140

141141
```javascript
142-
var randu = require( '@stdlib/random/base/randu' );
142+
var uniform = require( '@stdlib/random/array/uniform' );
143143
var EPS = require( '@stdlib/constants/float64/eps' );
144144
var quantile = require( '@stdlib/stats/base/dists/kumaraswamy/quantile' );
145145

@@ -149,19 +149,120 @@ var p;
149149
var y;
150150
var i;
151151

152-
for ( i = 0; i < 10; i++ ) {
153-
p = randu();
154-
a = ( randu()*5.0 ) + EPS;
155-
b = ( randu()*5.0 ) + EPS;
156-
y = quantile( p, a, b );
157-
console.log( 'p: %d, a: %d, b: %d, Q(p;a,b): %d', p.toFixed( 4 ), a.toFixed( 4 ), b.toFixed( 4 ), y.toFixed( 4 ) );
152+
p = uniform( 10, 0.0, 1.0 );
153+
a = uniform( 10, EPS, 5.0 );
154+
b = uniform( 10, EPS, 5.0 );
155+
156+
for ( i = 0; i < p.length; i++ ) {
157+
y = quantile( p[ i ], a[ i ], b[ i ] );
158+
console.log( 'p: %d, a: %d, b: %d, Q(p;a,b): %d', p[ i ].toFixed( 4 ), a[ i ].toFixed( 4 ), b[ i ].toFixed( 4 ), y.toFixed( 4 ) );
158159
}
159160
```
160161

161162
</section>
162163

163164
<!-- /.examples -->
164165

166+
<!-- C interface documentation. -->
167+
168+
* * *
169+
170+
<section class="c">
171+
172+
## C APIs
173+
174+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
175+
176+
<section class="intro">
177+
178+
</section>
179+
180+
<!-- /.intro -->
181+
182+
<!-- C usage documentation. -->
183+
184+
<section class="usage">
185+
186+
### Usage
187+
188+
```c
189+
#include "stdlib/stats/base/dists/kumaraswamy/quantile.h"
190+
```
191+
192+
#### stdlib_base_dists_kumaraswamy_quantile( p, a, b )
193+
194+
Evaluates the quantile function of a Kumaraswamy's double bounded distribution.
195+
196+
```c
197+
double out = stdlib_base_dists_kumaraswamy_quantile( 0.5, 1.0, 1.0 );
198+
// returns 0.5
199+
```
200+
201+
The function accepts the following arguments:
202+
203+
- **p**: `[in] double` probability.
204+
- **a**: `[in] double` first shape parameter.
205+
- **b**: `[in] double` second shape parameter.
206+
207+
```c
208+
double stdlib_base_dists_kumaraswamy_quantile( const double p, const
209+
double a, const double b );
210+
```
211+
212+
</section>
213+
214+
<!-- /.usage -->
215+
216+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
217+
218+
<section class="notes">
219+
220+
</section>
221+
222+
<!-- /.notes -->
223+
224+
<!-- C API usage examples. -->
225+
226+
<section class="examples">
227+
228+
### Examples
229+
230+
```c
231+
#include "stdlib/stats/base/dists/kumaraswamy/quantile.h"
232+
#include "stdlib/constants/float64/eps.h"
233+
#include <stdlib.h>
234+
#include <stdio.h>
235+
236+
static double random_uniform( const double min, const double max ) {
237+
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
238+
return min + ( v*(max-min) );
239+
}
240+
241+
int main( void ) {
242+
double p;
243+
double a;
244+
double b;
245+
double y;
246+
int i;
247+
248+
for ( i = 0; i < 25; i++ ) {
249+
p = random_uniform( 0.0, 1.0 );
250+
a = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 5.0 );
251+
b = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 5.0 );
252+
y = stdlib_base_dists_kumaraswamy_quantile( p, a, b );
253+
printf( "p: %lf, a: %lf, b: %lf, Q(p;a,b): %lf\n", p, a, b, y );
254+
}
255+
}
256+
```
257+
258+
</section>
259+
260+
<!-- /.examples -->
261+
262+
</section>
263+
264+
<!-- /.c -->
265+
165266
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
166267

167268
<section class="related">

lib/node_modules/@stdlib/stats/base/dists/kumaraswamy/quantile/benchmark/benchmark.js

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

2323
var bench = require( '@stdlib/bench' );
24-
var randu = require( '@stdlib/random/base/randu' );
24+
var uniform = require( '@stdlib/random/array/uniform' );
2525
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2626
var EPS = require( '@stdlib/constants/float64/eps' );
2727
var pkg = require( './../package.json' ).name;
@@ -31,18 +31,21 @@ var quantile = require( './../lib' );
3131
// MAIN //
3232

3333
bench( pkg, function benchmark( b ) {
34+
var len;
3435
var a;
3536
var s;
3637
var p;
3738
var y;
3839
var i;
3940

41+
len = 100;
42+
p = uniform( len, 0.0, 1.0 );
43+
a = uniform( len, EPS, 5.0 );
44+
s = uniform( len, EPS, 5.0 );
45+
4046
b.tic();
4147
for ( i = 0; i < b.iterations; i++ ) {
42-
p = randu() + EPS;
43-
a = ( randu()*100.0 ) + EPS;
44-
s = ( randu()*100.0 ) + EPS;
45-
y = quantile( p, a, s );
48+
y = quantile( p[ i % len ], a[ i % len ], s[ i % len ] );
4649
if ( isnan( y ) ) {
4750
b.fail( 'should not return NaN' );
4851
}
@@ -66,11 +69,11 @@ bench( pkg+':factory', function benchmark( b ) {
6669
a = 100.56789;
6770
s = 55.54321;
6871
myQuantile = quantile.factory( a, s );
72+
p = uniform( 100, 0.0, 1.0 );
6973

7074
b.tic();
7175
for ( i = 0; i < b.iterations; i++ ) {
72-
p = randu() + EPS;
73-
y = myQuantile( p );
76+
y = myQuantile( p[ i % p.length ] );
7477
if ( isnan( y ) ) {
7578
b.fail( 'should not return NaN' );
7679
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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' );
25+
var uniform = require( '@stdlib/random/array/uniform' );
26+
var isnan = require( '@stdlib/math/base/assert/is-nan' );
27+
var EPS = require( '@stdlib/constants/float64/eps' );
28+
var tryRequire = require( '@stdlib/utils/try-require' );
29+
var pkg = require( './../package.json' ).name;
30+
31+
32+
// VARIABLES //
33+
34+
var quantile = tryRequire( resolve( __dirname, './../lib/native.js' ) );
35+
var opts = {
36+
'skip': ( quantile instanceof Error )
37+
};
38+
39+
40+
// MAIN //
41+
42+
bench( pkg+'::native', opts, function benchmark( b ) {
43+
var len;
44+
var a;
45+
var s;
46+
var p;
47+
var y;
48+
var i;
49+
50+
len = 100;
51+
p = uniform( len, 0.0, 1.0 );
52+
a = uniform( len, EPS, 5.0 );
53+
s = uniform( len, EPS, 5.0 );
54+
55+
b.tic();
56+
for ( i = 0; i < b.iterations; i++ ) {
57+
y = quantile( p[ i % len ], a[ i % len ], s[ i % len ] );
58+
if ( isnan( y ) ) {
59+
b.fail( 'should not return NaN' );
60+
}
61+
}
62+
b.toc();
63+
if ( isnan( y ) ) {
64+
b.fail( 'should not return NaN' );
65+
}
66+
b.pass( 'benchmark finished' );
67+
b.end();
68+
});

0 commit comments

Comments
 (0)