Skip to content

Commit ed803eb

Browse files
chore: update all files acc to test
--- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: failed ---
1 parent f5ead5f commit ed803eb

File tree

11 files changed

+174
-45
lines changed

11 files changed

+174
-45
lines changed

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,17 +169,18 @@ for ( i = 0; i < 10; i++ ) {
169169
#include "stdlib/stats/base/dists/t/quantile.h"
170170
```
171171

172-
#### stdlib_base_dists_t_quantile( v )
172+
#### stdlib_base_dists_t_quantile( p, v )
173173

174-
Returns the standard deviation of a Student's t distribution.
174+
Returns the [quantile function][quantile-function] for a [Student's t][t-distribution] distribution with degrees of freedom `v` with probability `p`.
175175

176176
```c
177-
double out = stdlib_base_dists_t_quantile( 9.0 );
178-
// returns 0.0
177+
double out = stdlib_base_dists_t_quantile( 1.9, 1.0 );
178+
// returns NaN
179179
```
180180

181181
The function accepts the following arguments:
182182

183+
- **p**: `[in] double` probability
183184
- **v**: `[in] double` degrees of freedom.
184185

185186
```c
@@ -215,14 +216,16 @@ static double random_uniform( const double min, const double max ) {
215216
}
216217
217218
int main( void ) {
219+
double p;
218220
double v;
219221
double y;
220222
int i;
221223
222224
for ( i = 0; i < 25; i++ ) {
223-
v = random_uniform( 0.0, 20.0 );
225+
p = random_uniform( 0.0, 10.0 );
226+
v = random_uniform( 0.0, 10.0 ) * 10.0;
224227
y = stdlib_base_dists_t_quantile( v );
225-
printf( "v: %lf, SD(X;v): %lf\n", v, y );
228+
printf( "p: %lf, v: %lf, Q(p;v): %lf\n", p, v, y );
226229
}
227230
}
228231
```

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
var bench = require( '@stdlib/bench' );
2424
var Float64Array = require( '@stdlib/array/float64' );
2525
var ceil = require( '@stdlib/math/base/special/ceil' );
26-
var randu = require( '@stdlib/random/base/randu' );
26+
var uniform = require( '@stdlib/random/base/uniform' );
2727
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2828
var pkg = require( './../package.json' ).name;
2929
var quantile = require( './../lib' );
@@ -39,16 +39,16 @@ bench( pkg, function benchmark( b ) {
3939
var i;
4040

4141
len = 100;
42+
p = new Float64Array( len );
4243
v = new Float64Array( len );
4344
for ( i = 0; i < len; i++ ) {
44-
v[ i ] = ( randu() * 100.0 ) + 3.0;
45+
p[ i ] = uniform();
46+
v[ i ] = ceil( uniform( 0.0, 100.0 ) );
4547
}
4648

4749
b.tic();
4850
for ( i = 0; i < b.iterations; i++ ) {
49-
p = randu();
50-
v = ceil( randu()*100.0 );
51-
y = quantile( p, v );
51+
y = quantile( p[ i % len ], v[ i % len ] );
5252
if ( isnan( y ) ) {
5353
b.fail( 'should not return NaN' );
5454
}
@@ -73,7 +73,7 @@ bench( pkg+':factory', function benchmark( b ) {
7373

7474
b.tic();
7575
for ( i = 0; i < b.iterations; i++ ) {
76-
p = randu();
76+
p = uniform();
7777
y = myquantile( p );
7878
if ( isnan( y ) ) {
7979
b.fail( 'should not return NaN' );

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench' );
2525
var Float64Array = require( '@stdlib/array/float64' );
2626
var tryRequire = require( '@stdlib/utils/try-require' );
27-
var randu = require( '@stdlib/random/base/randu' );
27+
var uniform = require( '@stdlib/random/base/uniform' );
28+
var ceil = require( '@stdlib/math/base/special/ceil' );
2829
var isnan = require( '@stdlib/math/base/assert/is-nan' );
29-
var EPS = require( '@stdlib/constants/float64/eps' );
3030
var pkg = require( './../package.json' ).name;
3131

3232

@@ -43,18 +43,21 @@ var opts = {
4343
bench( pkg+'::native', opts, function benchmark( b ) {
4444
var len;
4545
var v;
46+
var p;
4647
var y;
4748
var i;
4849

4950
len = 100;
51+
p = new Float64Array( len );
5052
v = new Float64Array( len );
5153
for ( i = 0; i < len; i++ ) {
52-
v[ i ] = ( randu() * 20.0 ) + 3.0 + EPS;
54+
p[ i ] = uniform();
55+
v[ i ] = ceil( uniform( 0.0, 100.0 ) );
5356
}
5457

5558
b.tic();
5659
for ( i = 0; i < b.iterations; i++ ) {
57-
y = quantile( v[ i % len ] );
60+
y = quantile( p[ i % len ], v[ i % len ] );
5861
if ( isnan( y ) ) {
5962
b.fail( 'should not return NaN' );
6063
}

lib/node_modules/@stdlib/stats/base/dists/t/quantile/benchmark/c/benchmark.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,18 +93,20 @@ static double random_uniform( const double min, const double max ) {
9393
*/
9494
static double benchmark( void ) {
9595
double elapsed;
96+
double p[ 100 ];
9697
double v[ 100 ];
9798
double y;
9899
double t;
99100
int i;
100101

101102
for ( i = 0; i < 100; i++ ) {
102-
v[ i ] = random_uniform( 0.0, 20.0 ) + 3.0;
103+
p[ i ] = random_uniform( 0.0, 20.0 );
104+
v[ i ] = random_uniform( 0.0, 100.0 );
103105
}
104106

105107
t = tic();
106108
for ( i = 0; i < ITERATIONS; i++ ) {
107-
y = stdlib_base_dists_t_quantile( v[ i % 100 ] );
109+
y = stdlib_base_dists_t_quantile( p[ i % 100 ], v[ i % 100 ] );
108110
if ( y != y ) {
109111
printf( "should not return NaN\n" );
110112
break;

lib/node_modules/@stdlib/stats/base/dists/t/quantile/examples/c/example.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@ static double random_uniform( const double min, const double max ) {
2626
}
2727

2828
int main( void ) {
29+
double p;
2930
double v;
3031
double y;
3132
int i;
3233

3334
for ( i = 0; i < 25; i++ ) {
34-
v = random_uniform( 0.0, 20.0 );
35+
p = random_uniform( 0.0, 20.0);
36+
v = random_uniform( 0.0, 100.0 );
3537
y = stdlib_base_dists_t_quantile( v );
36-
printf( "v: %lf, quant(X;v): %lf\n", v, y );
38+
printf( "p: %lf, v: %lf, Q(p;v): %lf\n", p, v, y );
3739
}
3840
}

lib/node_modules/@stdlib/stats/base/dists/t/quantile/include/stdlib/stats/base/dists/t/quantile.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ extern "C" {
2929
/**
3030
* Returns the skewness of a Student's t distribution.
3131
*/
32-
double stdlib_base_dists_t_quantile( const double v );
32+
double stdlib_base_dists_t_quantile( const double p, const double v );
3333

3434
#ifdef __cplusplus
3535
}

lib/node_modules/@stdlib/stats/base/dists/t/quantile/lib/native.js

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,34 +26,42 @@ var addon = require( './../src/addon.node' );
2626
// MAIN //
2727

2828
/**
29-
* Returns the skewness of a Student's t distribution.
29+
* Evaluates the quantile function for a Student's t distribution with degrees of freedom `v` at a probability `p`.
3030
*
31-
* @private
32-
* @param {NonNegativeNumber} v - degrees of freedom
33-
* @returns {NonNegativeNumber} quantile
31+
* @param {Probability} p - input value
32+
* @param {PositiveNumber} v - degrees of freedom
33+
* @returns {number} evaluated quantile function
3434
*
3535
* @example
36-
* var v = quantile( 9.0 );
37-
* // returns 0.0
36+
* var y = quantile( 0.8, 1.0 );
37+
* // returns ~1.376
38+
*
39+
* @example
40+
* var y = quantile( 0.1, 1.0 );
41+
* // returns ~-3.078
3842
*
3943
* @example
40-
* var v = quantile( 4.0 );
44+
* var y = quantile( 0.5, 0.1 );
4145
* // returns 0.0
4246
*
4347
* @example
44-
* var v = quantile( 0.5 );
48+
* var y = quantile( -0.2, 0.1 );
49+
* // returns NaN
50+
*
51+
* @example
52+
* var y = quantile( NaN, 1.0 );
4553
* // returns NaN
4654
*
4755
* @example
48-
* var v = quantile( -0.2 );
56+
* var y = quantile( 0.0, NaN );
4957
* // returns NaN
5058
*
5159
* @example
52-
* var v = quantile( NaN );
60+
* var y = quantile( 0.5, -1.0 );
5361
* // returns NaN
5462
*/
55-
function quantile( v ) {
56-
return addon( v );
63+
function quantile( p, v ) {
64+
return addon( p, v );
5765
}
5866

5967

lib/node_modules/@stdlib/stats/base/dists/t/quantile/manifest.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@
3838
"libraries": [],
3939
"libpath": [],
4040
"dependencies": [
41-
"@stdlib/math/base/napi/unary",
41+
"@stdlib/math/base/napi/binary",
42+
"@stdlib/math/base/special/kernel-betaincinv",
43+
"@stdlib/math/base/special/sqrt",
44+
"@stdlib/math/base/special/signum",
4245
"@stdlib/math/base/assert/is-nan"
4346
]
4447
},
@@ -54,7 +57,9 @@
5457
"libraries": [],
5558
"libpath": [],
5659
"dependencies": [
57-
"@stdlib/math/base/assert/is-nan"
60+
"@stdlib/math/base/assert/is-nan",
61+
"@stdlib/math/base/special/sqrt",
62+
"@stdlib/math/base/special/signum"
5863
]
5964
},
6065
{
@@ -69,7 +74,8 @@
6974
"libraries": [],
7075
"libpath": [],
7176
"dependencies": [
72-
"@stdlib/math/base/assert/is-nan"
77+
"@stdlib/math/base/assert/is-nan",
78+
"@stdlib/math/base/special/sqrt"
7379
]
7480
}
7581
]

lib/node_modules/@stdlib/stats/base/dists/t/quantile/src/addon.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*/
1818

1919
#include "stdlib/stats/base/dists/t/quantile.h"
20-
#include "stdlib/math/base/napi/unary.h"
20+
#include "stdlib/math/base/napi/binary.h"
2121

2222
// cppcheck-suppress shadowFunction
23-
STDLIB_MATH_BASE_NAPI_MODULE_D_D( stdlib_base_dists_t_quantile)
23+
STDLIB_MATH_BASE_NAPI_MODULE_DD_D( stdlib_base_dists_t_quantile)

lib/node_modules/@stdlib/stats/base/dists/t/quantile/src/main.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,35 @@
1717
*/
1818

1919
#include "stdlib/stats/base/dists/t/quantile.h"
20+
#include "stdlib/math/base/special/kernel-betaincinv.h"
21+
#include "stdlib/math/base/special/signum.h"
22+
#include "stdlib/math/base/special/sqrt.h"
2023
#include "stdlib/math/base/assert/is_nan.h"
2124

2225
/**
2326
* Returns the skewness of a Student's t distribution.
2427
*
28+
* @param p probability
2529
* @param v degrees of freedom
26-
* @return quantile
30+
* @return evaluated quantile function
2731
*
2832
* @example
2933
* double y = stdlib_base_t_quantile( 9.0 );
3034
* // returns 0.0
3135
*/
32-
double stdlib_base_dists_t_quantile( const double v ) {
33-
if ( stdlib_base_is_nan( v ) || v <= 3.0 ) {
36+
double stdlib_base_dists_t_quantile( const double p, const double v ) {
37+
double prob;
38+
double xs;
39+
if (
40+
stdlib_base_is_nan( v ) ||
41+
stdlib_base_is_nan( p ) ||
42+
v <= 0.0 ||
43+
p < 0.0 ||
44+
p > 1.0
45+
) {
3446
return 0.0 / 0.0; // NaN
3547
}
36-
return 0.0;
48+
prob = ( p > 0.5 ) ? 1.0 - p : p;
49+
xs = stdlib_base_kernelBetaincinv( v / 2.0, 0.5, 2.0 * prob, 1.0 - (2.0 * prob) );
50+
return stdlib_base_signum( p - 0.5 ) * stdlib_base_sqrt( v * xs[ 1 ] / xs[ 0 ] );
3751
}

0 commit comments

Comments
 (0)