Skip to content

Commit 25d7bde

Browse files
committed
chore: minor clean-up
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: passed - task: lint_c_examples status: passed - task: lint_c_benchmarks status: passed - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent fbce243 commit 25d7bde

File tree

9 files changed

+23
-25
lines changed

9 files changed

+23
-25
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@
2222

2323
var bench = require( '@stdlib/bench' );
2424
var Float64Array = require( '@stdlib/array/float64' );
25-
var randu = require( '@stdlib/random/base/randu' );
25+
var uniform = require( '@stdlib/random/base/uniform' );
2626
var isnan = require( '@stdlib/math/base/assert/is-nan' );
27+
var EPS = require( '@stdlib/constants/float64/eps' );
2728
var pkg = require( './../package.json' ).name;
2829
var mean = require( './../lib' );
2930

@@ -39,7 +40,7 @@ bench( pkg, function benchmark( b ) {
3940
len = 100;
4041
v = new Float64Array( len );
4142
for ( i = 0; i < len; i++ ) {
42-
v[ i ] = ( randu() * 100.0 ) + 1.0; // degrees of freedom > 1
43+
v[ i ] = uniform( 1.0+EPS, 100.0 ); // degrees of freedom > 1
4344
}
4445

4546
b.tic();

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@
2323
var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench' );
2525
var Float64Array = require( '@stdlib/array/float64' );
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 tryRequire = require( '@stdlib/utils/try-require' );
29+
var EPS = require( '@stdlib/constants/float64/eps' );
2930
var pkg = require( '@stdlib/stats/base/dists/t/mean/package.json' ).name;
3031

3132

@@ -48,7 +49,7 @@ bench( pkg + '::native', opts, function benchmark( b ) {
4849
len = 100;
4950
v = new Float64Array( len );
5051
for ( i = 0; i < len; i++ ) {
51-
v[ i ] = ( randu() * 100.0 ) + 1.0; // degrees of freedom > 1
52+
v[ i ] = uniform( 1.0+EPS, 100.0 ); // degrees of freedom > 1
5253
}
5354

5455
b.tic();

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

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

19-
#include <sys/time.h>
2019
#include "stdlib/stats/base/dists/t/mean.h"
20+
#include <sys/time.h>
2121
#include <math.h>
2222
#include <stdio.h>
2323
#include <stdlib.h>
@@ -99,7 +99,7 @@ static double benchmark( void ) {
9999
int i;
100100

101101
for ( i = 0; i < 100; i++ ) {
102-
v[ i ] = random_uniform( 1.0, 100.0 ); // degrees of freedom > 1
102+
v[ i ] = random_uniform( 1.1, 100.0 ); // degrees of freedom > 1
103103
}
104104

105105
t = tic();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
* limitations under the License.
1717
*/
1818

19-
#include "stdlib/math/base/assert/is_nan.h"
2019
#include "stdlib/stats/base/dists/t/mean.h"
20+
#include "stdlib/math/base/assert/is_nan.h"
2121

2222
/**
2323
* Evaluates the mean for a t-distribution with degrees of freedom `v`.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
* limitations under the License.
1717
*/
1818

19-
#include <sys/time.h>
2019
#include "stdlib/stats/base/dists/t/mode.h"
20+
#include <sys/time.h>
2121
#include <math.h>
2222
#include <stdio.h>
2323
#include <stdlib.h>

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,6 @@ extern "C" {
2828

2929
/**
3030
* Evaluates the mode for a Student's t-distribution with degrees of freedom `v`.
31-
*
32-
* @param v degrees of freedom
33-
* @return mode
34-
*
35-
* @example
36-
* double y = stdlib_base_dists_t_mode( 5.0 );
37-
* // returns 0.0
3831
*/
3932
double stdlib_base_dists_t_mode( const double v );
4033

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
* limitations under the License.
1717
*/
1818

19-
#include "stdlib/math/base/assert/is_nan.h"
2019
#include "stdlib/stats/base/dists/t/mode.h"
20+
#include "stdlib/math/base/assert/is_nan.h"
2121

2222
/**
2323
* Evaluates the mode for a Student's t-distribution with degrees of freedom `v`.

lib/node_modules/@stdlib/stats/base/dists/triangular/variance/benchmark/c/benchmark.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,15 @@ static double tic( void ) {
7575
}
7676

7777
/**
78-
* Generates a random number on the interval [0,20).
78+
* Generates a random number on the interval [min,max).
7979
*
80-
* @return random number
80+
* @param min minimum value (inclusive)
81+
* @param max maximum value (exclusive)
82+
* @return random number
8183
*/
82-
static double rand_double( void ) {
83-
int r = rand();
84-
return 20.0*(double)r / ( (double)RAND_MAX + 1.0 );
84+
static double random_uniform( const double min, const double max ) {
85+
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
86+
return min + ( v*(max-min) );
8587
}
8688

8789
/**
@@ -98,10 +100,11 @@ static double benchmark( void ) {
98100
double t;
99101
int i;
100102

103+
// Generate random parameters for the triangular distribution:
101104
for ( i = 0; i < 100; i++ ) {
102-
a[ i ] = rand_double() * 20.0;
103-
b[ i ] = ( rand_double() * 20.0 ) + a[ i ];
104-
c[ i ] = ( rand_double() * ( b[i] - a[i] ) ) + a[i];
105+
a[ i ] = random_uniform( 0.0, 20.0 ); // Lower bound
106+
b[ i ] = random_uniform( a[i], a[i]+20.0 ); // Upper bound
107+
c[ i ] = random_uniform( a[i], b[i] ); // Mode
105108
}
106109

107110
t = tic();

lib/node_modules/@stdlib/stats/base/dists/triangular/variance/examples/c/example.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ int main( void ) {
3535
for ( i = 0; i < 25; i++ ) {
3636
a = random_uniform( 0.0, 10.0 );
3737
b = random_uniform( a, a+10.0 );
38-
c = a + (b - a) * random_uniform( 0.0, 1.0 );
38+
c = random_uniform( a, b );
3939
y = stdlib_base_dists_triangular_variance( a, b, c );
4040
printf( "a: %lf, b: %lf, c: %lf, Var(X;a,b,c): %lf\n", a, b, c, y );
4141
}

0 commit comments

Comments
 (0)