Skip to content

Commit c61bddc

Browse files
chore: clean up
1 parent b8a730b commit c61bddc

File tree

12 files changed

+94
-107
lines changed

12 files changed

+94
-107
lines changed

lib/node_modules/@stdlib/stats/base/dists/betaprime/pdf/README.md

Lines changed: 20 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -187,41 +187,11 @@ for ( i = 0; i < 10; i++ ) {
187187

188188
#### stdlib_base_dists_betaprime_pdf( x, alpha, beta )
189189

190-
Evaluates the probability density function (PDF) for a beta prime distribution with first shape parameter `alpha` and second shape parameter `beta` at a value `x`.
190+
Evaluates the probability density function (PDF) for a beta prime distribution with first shape parameter `alpha` and second shape parameter `beta`.
191191

192192
```c
193193
double y = stdlib_base_dists_betaprime_pdf( 0.5, 1.0, 1.0 );
194194
// returns ~0.444
195-
196-
y = stdlib_base_dists_betaprime_pdf( 0.5, 2.0, 4.0 );
197-
// returns ~0.878
198-
199-
y = stdlib_base_dists_betaprime_pdf( 0.2, 2.0, 2.0 );
200-
// returns ~0.579
201-
202-
y = stdlib_base_dists_betaprime_pdf( 0.8, 4.0, 4.0 );
203-
// returns ~0.65
204-
205-
y = stdlib_base_dists_betaprime_pdf( -0.5, 4.0, 2.0 );
206-
// returns ~0.0
207-
208-
y = stdlib_base_dists_betaprime_pdf( 1.5, 4.0, 2.0 );
209-
// returns ~NaN
210-
211-
y = stdlib_base_dists_betaprime_pdf( 0.5, -1.0, 0.5 );
212-
// returns NaN
213-
214-
y = stdlib_base_dists_betaprime_pdf( 0.5, 0.5, -1.0 );
215-
// returns NaN
216-
217-
y = stdlib_base_dists_betaprime_pdf( NaN, 1.0, 1.0 );
218-
// returns NaN
219-
220-
y = stdlib_base_dists_betaprime_pdf( 0.5, NaN, 1.0 );
221-
// returns NaN
222-
223-
y = stdlib_base_dists_betaprime_pdf( 0.5, 1.0, NaN );
224-
// returns NaN
225195
```
226196

227197
The function accepts the following arguments:
@@ -238,7 +208,7 @@ double stdlib_base_dists_betaprime_pdf( const double x, double alpha, const doub
238208
239209
<!-- /.usage -->
240210
241-
<!-- C API usage notes. Make sure to keep an empty line after the `section`
211+
<!-- C API usage notes. Make sure to keep an empty line after the `section`
242212
element and another before the `/section` close. -->
243213
244214
<section class="notes">
@@ -259,20 +229,25 @@ element and another before the `/section` close. -->
259229
#include <stdlib.h>
260230
#include <stdio.h>
261231
232+
static double random_uniform( const double min, const double max ) {
233+
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
234+
return min + ( v*(max-min) );
235+
}
236+
262237
int main( void ) {
263-
double alpha;
264-
double beta;
265-
double x;
266-
double y;
267-
int i;
268-
269-
for ( i = 0; i < 10; i++ ) {
270-
x = ( (double)rand() / (double)RAND_MAX );
271-
alpha = ( ( (double)rand() / (double)RAND_MAX )*5.0 ) + STDLIB_CONSTANT_FLOAT64_EPS;
272-
beta = ( ( (double)rand() / (double)RAND_MAX )*5.0 ) + STDLIB_CONSTANT_FLOAT64_EPS;
273-
y = stdlib_base_dists_betaprime_pdf( x, alpha, beta );
274-
printf( "x: %1f, α: %1f, β: %1f, f(x;α,β): %lf\n", x, alpha, beta, y );
275-
}
238+
double alpha;
239+
double beta;
240+
double x;
241+
double y;
242+
int i;
243+
244+
for ( i = 0; i < 10; i++ ) {
245+
x = random_uniform( 0.0, 1.0 );
246+
alpha = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 5.0 );
247+
beta = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 5.0 );
248+
y = stdlib_base_dists_betaprime_pdf( x, alpha, beta );
249+
printf( "x: %1f, α: %1f, β: %1f, f(x;α,β): %lf\n", x, alpha, beta, y );
250+
}
276251
}
277252
```
278253

lib/node_modules/@stdlib/stats/base/dists/betaprime/pdf/benchmark/benchmark.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
var bench = require( '@stdlib/bench' );
2424
var randu = require( '@stdlib/random/base/randu' );
25+
var uniform = require( '@stdlib/random/base/uniform' );
26+
var Float64Array = require( '@stdlib/array/float64' );
2527
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2628
var EPS = require( '@stdlib/constants/float64/eps' );
2729
var pkg = require( './../package.json' ).name;
@@ -33,16 +35,28 @@ var pdf = require( './../lib' );
3335
bench( pkg, function benchmark( b ) {
3436
var alpha;
3537
var beta;
38+
var len;
3639
var x;
3740
var y;
3841
var i;
3942

43+
len = 100;
44+
alpha = new Float64Array( len );
45+
for ( i = 0; i < len; i++ ) {
46+
alpha[ i ] = uniform( EPS, 100.0 );
47+
}
48+
beta = new Float64Array( len );
49+
for ( i = 0; i < len; i++ ) {
50+
beta[ i ] = uniform( EPS, 100.0 );
51+
}
52+
x = new Float64Array( len );
53+
for ( i = 0; i < len; i++ ) {
54+
x[ i ] = uniform( EPS, 2.0 );
55+
}
56+
4057
b.tic();
4158
for ( i = 0; i < b.iterations; i++ ) {
42-
x = ( randu()*2.0 ) + EPS;
43-
alpha = ( randu()*100.0 ) + EPS;
44-
beta = ( randu()*100.0 ) + EPS;
45-
y = pdf( x, alpha, beta );
59+
y = pdf( x[ i%100 ], alpha[ i%100 ], beta[ i%100 ] );
4660
if ( isnan( y ) ) {
4761
b.fail( 'should not return NaN' );
4862
}

lib/node_modules/@stdlib/stats/base/dists/betaprime/pdf/benchmark/benchmark.native.js

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222

2323
var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench' );
25-
var randu = require( '@stdlib/random/base/randu' );
25+
var uniform = require( '@stdlib/random/base/uniform' );
26+
var Float64Array = require( '@stdlib/array/float64' );
2627
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2728
var tryRequire = require( '@stdlib/utils/try-require' );
2829
var EPS = require( '@stdlib/constants/float64/eps' );
@@ -42,44 +43,28 @@ var opts = {
4243
bench( pkg+'::native', opts, function benchmark( b ) {
4344
var alpha;
4445
var beta;
46+
var len;
4547
var x;
4648
var y;
4749
var i;
4850

49-
b.tic();
50-
for ( i = 0; i < b.iterations; i++ ) {
51-
x = ( randu()*2.0 ) + EPS;
52-
alpha = ( randu()*100.0 ) + EPS;
53-
beta = ( randu()*100.0 ) + EPS;
54-
y = pdf( x, alpha, beta );
55-
if ( isnan( y ) ) {
56-
b.fail( 'should not return NaN' );
57-
}
51+
len = 100;
52+
alpha = new Float64Array( len );
53+
for ( i = 0; i < len; i++ ) {
54+
alpha[ i ] = uniform( EPS, 100.0 );
5855
}
59-
b.toc();
60-
if ( isnan( y ) ) {
61-
b.fail( 'should not return NaN' );
56+
beta = new Float64Array( len );
57+
for ( i = 0; i < len; i++ ) {
58+
beta[ i ] = uniform( EPS, 100.0 );
59+
}
60+
x = new Float64Array( len );
61+
for ( i = 0; i < len; i++ ) {
62+
x[ i ] = uniform( EPS, 2.0 );
6263
}
63-
b.pass( 'benchmark finished' );
64-
b.end();
65-
});
66-
67-
bench( pkg+':factory', opts, function benchmark( b ) {
68-
var mypdf;
69-
var alpha;
70-
var beta;
71-
var x;
72-
var y;
73-
var i;
74-
75-
alpha = 100.56789;
76-
beta = 55.54321;
77-
mypdf = pdf.factory( alpha, beta );
7864

7965
b.tic();
8066
for ( i = 0; i < b.iterations; i++ ) {
81-
x = ( randu()*2.0 ) + EPS;
82-
y = mypdf( x );
67+
y = pdf( x[ i%100 ], alpha[ i%100 ], beta[ i%100 ] );
8368
if ( isnan( y ) ) {
8469
b.fail( 'should not return NaN' );
8570
}

lib/node_modules/@stdlib/stats/base/dists/betaprime/pdf/benchmark/c/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,4 @@ run: $(c_targets)
143143
clean:
144144
$(QUIET) -rm -f *.o *.out
145145

146-
.PHONY: clean
146+
.PHONY: clean

lib/node_modules/@stdlib/stats/base/dists/betaprime/pdf/benchmark/c/benchmark.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,19 +94,26 @@ static double random_uniform( const double min, const double max ) {
9494
*/
9595
static double benchmark( void ) {
9696
double elapsed;
97-
double alpha;
98-
double beta;
99-
double x;
97+
double alpha[ 100 ];
98+
double beta[ 100 ];
99+
double x[ 100 ];
100100
double y;
101101
double t;
102102
int i;
103103

104+
for ( i = 0; i < 100; i++ ) {
105+
alpha[ i ] = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 100.0 );
106+
}
107+
for ( i = 0; i < 100; i++ ) {
108+
beta[ i ] = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 100.0 );
109+
}
110+
for ( i = 0; i < 100; i++ ) {
111+
x[ i ] = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 2.0 );
112+
}
113+
104114
t = tic();
105115
for ( i = 0; i < ITERATIONS; i++ ) {
106-
x = ( ( (double)rand() / (double)RAND_MAX )*2.0 ) + STDLIB_CONSTANT_FLOAT64_EPS;
107-
alpha = ( ( (double)rand() / (double)RAND_MAX )*100.0 ) + STDLIB_CONSTANT_FLOAT64_EPS;
108-
beta = ( ( (double)rand() / (double)RAND_MAX )*100.0 ) + STDLIB_CONSTANT_FLOAT64_EPS;
109-
y = stdlib_base_dists_betaprime_pdf( x, alpha, beta );
116+
y = stdlib_base_dists_betaprime_pdf( x[ i%100 ], alpha[ i%100 ], beta[ i%100 ] );
110117
if ( y != y ) {
111118
printf( "should not return NaN\n" );
112119
break;

lib/node_modules/@stdlib/stats/base/dists/betaprime/pdf/binding.gyp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,4 +167,4 @@
167167
], # end actions
168168
}, # end target copy_addon
169169
], # end targets
170-
}
170+
}

lib/node_modules/@stdlib/stats/base/dists/betaprime/pdf/examples/c/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,4 @@ run: $(c_targets)
143143
clean:
144144
$(QUIET) -rm -f *.o *.out
145145

146-
.PHONY: clean
146+
.PHONY: clean

lib/node_modules/@stdlib/stats/base/dists/betaprime/pdf/examples/c/example.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,23 @@
2121
#include <stdlib.h>
2222
#include <stdio.h>
2323

24+
static double random_uniform( const double min, const double max ) {
25+
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
26+
return min + ( v*(max-min) );
27+
}
28+
2429
int main( void ) {
25-
double alpha;
26-
double beta;
27-
double x;
30+
double alpha;
31+
double beta;
32+
double x;
2833
double y;
2934
int i;
3035

3136
for ( i = 0; i < 10; i++ ) {
32-
x = ( (double)rand() / (double)RAND_MAX );
33-
alpha = ( ( (double)rand() / (double)RAND_MAX )*5.0 ) + STDLIB_CONSTANT_FLOAT64_EPS;
34-
beta = ( ( (double)rand() / (double)RAND_MAX )*5.0 ) + STDLIB_CONSTANT_FLOAT64_EPS;
35-
y = stdlib_base_dists_betaprime_pdf( x, alpha, beta );
36-
printf( "x: %1f, α: %1f, β: %1f, f(x;α,β): %lf\n", x, alpha, beta, y );
37+
x = random_uniform( 0.0, 1.0 );
38+
alpha = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 5.0 );
39+
beta = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 5.0 );
40+
y = stdlib_base_dists_betaprime_pdf( x, alpha, beta );
41+
printf( "x: %1f, α: %1f, β: %1f, f(x;α,β): %lf\n", x, alpha, beta, y );
3742
}
3843
}

lib/node_modules/@stdlib/stats/base/dists/betaprime/pdf/include/stdlib/stats/base/dists/betaprime/pdf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ extern "C" {
2727
#endif
2828

2929
/**
30-
* Evaluates the probability density function (PDF) for a beta prime distribution with first shape parameter `alpha` and second shape parameter `beta` at a value `x`.
30+
* Evaluates the probability density function (PDF) for a beta prime distribution with first shape parameter `alpha` and second shape parameter `beta`.
3131
*/
3232
double stdlib_base_dists_betaprime_pdf( const double x, const double alpha, const double beta );
3333

lib/node_modules/@stdlib/stats/base/dists/betaprime/pdf/src/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,4 @@ clean-addon:
6767
#/
6868
clean: clean-addon
6969

70-
.PHONY: clean
70+
.PHONY: clean

0 commit comments

Comments
 (0)