Skip to content

Commit c035eb8

Browse files
chore: clean up
1 parent 658f917 commit c035eb8

File tree

15 files changed

+71
-36
lines changed

15 files changed

+71
-36
lines changed

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ for ( i = 0; i < 10; i++ ) {
172172

173173
#### stdlib_base_dists_betaprime_mode( alpha, beta )
174174

175-
Evaluates the mode for a beta prime distribution with first shape parameter `alpha` and second shape parameter `beta`.
175+
Returns the mode for a beta prime distribution with first shape parameter `alpha` and second shape parameter `beta`.
176176

177177
```c
178178
double y = stdlib_base_dists_betaprime_mode( 1.0, 2.0 );
@@ -208,10 +208,15 @@ element and another before the `/section` close. -->
208208
### Examples
209209
210210
```c
211-
#include "stdlib/stats/base/dists/betaprime/mode.h"
212211
#include "stdlib/constants/float64/eps.h"
213-
#include <stdlib.h>
212+
#include "stdlib/stats/base/dists/betaprime/mode.h"
214213
#include <stdio.h>
214+
#include <stdlib.h>
215+
216+
static double random_uniform( const double min, const double max ) {
217+
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
218+
return min + ( v*(max-min) );
219+
}
215220
216221
int main( void ) {
217222
double alpha;
@@ -220,8 +225,8 @@ int main( void ) {
220225
int i;
221226
222227
for ( i = 0; i < 10; i++ ) {
223-
alpha = ( ( (double)rand() / (double)RAND_MAX )*10.0 ) + STDLIB_CONSTANT_FLOAT64_EPS;
224-
beta = ( ( (double)rand() / (double)RAND_MAX )*10.0 ) + 1.0 + STDLIB_CONSTANT_FLOAT64_EPS;
228+
alpha = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 10.0 );
229+
beta = random_uniform( 1.0 + STDLIB_CONSTANT_FLOAT64_EPS, 11.0 );
225230
y = stdlib_base_dists_betaprime_mode( alpha, beta );
226231
printf( "α: %1f, β: %1f, Mode(X;α,β): %lf\n", alpha, beta, y );
227232
}

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

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

2323
var bench = require( '@stdlib/bench' );
24-
var randu = require( '@stdlib/random/base/randu' );
24+
var uniform = require( '@stdlib/random/base/uniform' );
25+
var Float64Array = require( '@stdlib/array/float64' );
2526
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2627
var EPS = require( '@stdlib/constants/float64/eps' );
2728
var pkg = require( './../package.json' ).name;
@@ -33,14 +34,23 @@ var mode = require( './../lib' );
3334
bench( pkg, function benchmark( b ) {
3435
var alpha;
3536
var beta;
37+
var len;
3638
var y;
3739
var i;
3840

41+
len = 100;
42+
alpha = new Float64Array( len );
43+
for ( i = 0; i < len; i++ ) {
44+
alpha[ i ] = uniform( EPS, 10.0 );
45+
}
46+
beta = new Float64Array( len );
47+
for ( i = 0; i < len; i++ ) {
48+
beta[ i ] = uniform( EPS, 10.0 );
49+
}
50+
3951
b.tic();
4052
for ( i = 0; i < b.iterations; i++ ) {
41-
alpha = ( randu()*10.0 ) + EPS;
42-
beta = ( randu()*10.0 ) + EPS;
43-
y = mode( alpha, beta );
53+
y = mode( alpha[ i%100 ], beta[ i%100 ] );
4454
if ( isnan( y ) ) {
4555
b.fail( 'should not return NaN' );
4656
}

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

Lines changed: 14 additions & 4 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,14 +43,23 @@ var opts = {
4243
bench( pkg+'::native', opts, function benchmark( b ) {
4344
var alpha;
4445
var beta;
46+
var len;
4547
var y;
4648
var i;
4749

50+
len = 100;
51+
alpha = new Float64Array( len );
52+
for ( i = 0; i < len; i++ ) {
53+
alpha[ i ] = uniform( EPS, 10.0 );
54+
}
55+
beta = new Float64Array( len );
56+
for ( i = 0; i < len; i++ ) {
57+
beta[ i ] = uniform( EPS, 10.0 );
58+
}
59+
4860
b.tic();
4961
for ( i = 0; i < b.iterations; i++ ) {
50-
alpha = ( randu()*10.0 ) + EPS;
51-
beta = ( randu()*10.0 ) + EPS;
52-
y = mode( alpha, beta );
62+
y = mode( alpha[ i%100 ], beta[ i%100 ] );
5363
if ( isnan( y ) ) {
5464
b.fail( 'should not return NaN' );
5565
}

lib/node_modules/@stdlib/stats/base/dists/betaprime/mode/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/mode/benchmark/c/benchmark.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
* limitations under the License.
1717
*/
1818

19-
#include <sys/time.h>
20-
#include "stdlib/constants/float64/eps.h"
2119
#include "stdlib/stats/base/dists/betaprime/mode.h"
22-
#include <math.h>
23-
#include <stdio.h>
20+
#include "stdlib/constants/float64/eps.h"
2421
#include <stdlib.h>
22+
#include <stdio.h>
23+
#include <math.h>
2524
#include <time.h>
25+
#include <sys/time.h>
2626

2727
#define NAME "betaprime-mode"
2828
#define ITERATIONS 1000000
@@ -94,17 +94,22 @@ 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;
97+
double alpha[ 100 ];
98+
double beta[ 100 ];
9999
double y;
100100
double t;
101101
int i;
102102

103+
for ( i = 0; i < 100; i++ ) {
104+
alpha[ i ] = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 10.0 );
105+
}
106+
for ( i = 0; i < 100; i++ ) {
107+
beta[ i ] = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 10.0 );
108+
}
109+
103110
t = tic();
104111
for ( i = 0; i < ITERATIONS; i++ ) {
105-
alpha = ( ( (double)rand() / (double)RAND_MAX ) * 10.0 ) + STDLIB_CONSTANT_FLOAT64_EPS;
106-
beta = ( ( (double)rand() / (double)RAND_MAX ) * 10.0 ) + STDLIB_CONSTANT_FLOAT64_EPS;
107-
y = stdlib_base_dists_betaprime_mode( alpha, beta );
112+
y = stdlib_base_dists_betaprime_mode( alpha[ i%100 ], beta[ i%100 ] );
108113
if ( y != y ) {
109114
printf( "should not return NaN\n" );
110115
break;

lib/node_modules/@stdlib/stats/base/dists/betaprime/mode/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/mode/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/mode/examples/c/example.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,20 @@
2121
#include <stdio.h>
2222
#include <stdlib.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 ) {
2530
double alpha;
2631
double beta;
2732
double y;
2833
int i;
2934

3035
for ( i = 0; i < 10; i++ ) {
31-
alpha = ( ( (double)rand() / (double)RAND_MAX ) * 10.0 ) + STDLIB_CONSTANT_FLOAT64_EPS;
32-
beta = ( ( (double)rand() / (double)RAND_MAX ) * 10.0 ) + 1.0 + STDLIB_CONSTANT_FLOAT64_EPS;
36+
alpha = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 10.0 );
37+
beta = random_uniform( 1.0 + STDLIB_CONSTANT_FLOAT64_EPS, 11.0 );
3338
y = stdlib_base_dists_betaprime_mode( alpha, beta );
3439
printf( "α: %1f, β: %1f, Mode(X;α,β): %lf\n", alpha, beta, y );
3540
}

lib/node_modules/@stdlib/stats/base/dists/betaprime/mode/include.gypi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,4 @@
5050
'<!@(node -e "var arr = require(\'@stdlib/utils/library-manifest\')(\'./manifest.json\',{},{\'basedir\':process.cwd(),\'paths\':\'posix\'}).libpath; for ( var i = 0; i < arr.length; i++ ) { console.log( arr[ i ] ); }")',
5151
],
5252
}, # end variables
53-
}
53+
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ extern "C" {
2727
#endif
2828

2929
/**
30-
* Evaluates the mode for a beta prime distribution with first shape parameter `alpha` and second shape parameter `beta`.
30+
* Returns the mode for a beta prime distribution with first shape parameter `alpha` and second shape parameter `beta`.
3131
*/
3232
double stdlib_base_dists_betaprime_mode( const double alpha, const double beta );
3333

3434
#ifdef __cplusplus
3535
}
3636
#endif
3737

38-
#endif // !STDLIB_STATS_BASE_DISTS_BETAPRIME_MODE_H
38+
#endif // !STDLIB_STATS_BASE_DISTS_BETAPRIME_MODE_H

0 commit comments

Comments
 (0)