Skip to content

Commit 7361d34

Browse files
committed
chore: reapply suggestions from PR review
--- 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: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: missing_dependencies - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - 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 --- --- 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: passed - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: passed - task: run_c_benchmarks status: passed - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: passed - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na ---
1 parent 9977cde commit 7361d34

File tree

7 files changed

+53
-21
lines changed

7 files changed

+53
-21
lines changed

lib/node_modules/@stdlib/stats/base/dists/chisquare/kurtosis/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ int main( void ) {
193193
int i;
194194
195195
for ( i = 0; i < 10; i++ ) {
196-
k = random_uniform( 0.1, 10.0 ); // Ensure `k` is positive
196+
k = random_uniform( 1.0, 10.0 );
197197
result = stdlib_base_dists_chisquare_kurtosis( k );
198198
printf( "k: %lf, Kurt(X,k): %lf \n", k, result );
199199
}

lib/node_modules/@stdlib/stats/base/dists/chisquare/kurtosis/benchmark/benchmark.native.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ var bench = require( '@stdlib/bench' );
2525
var Float64Array = require( '@stdlib/array/float64' );
2626
var uniform = require( '@stdlib/random/base/uniform' );
2727
var isnan = require( '@stdlib/math/base/assert/is-nan' );
28+
var EPS = require( '@stdlib/constants/float64/eps' );
2829
var tryRequire = require( '@stdlib/utils/try-require' );
2930
var pkg = require( './../package.json' ).name;
3031

@@ -48,7 +49,7 @@ bench( pkg+'::native', opts, function benchmark( b ) {
4849
len = 100;
4950
k = new Float64Array( len );
5051
for ( i = 0; i < len; i++ ) {
51-
k[ i ] = uniform( 0.1, 10.0 ); // Ensure k > 0
52+
k[ i ] = uniform( EPS, 20.0 );
5253
}
5354

5455
b.tic();

lib/node_modules/@stdlib/stats/base/dists/chisquare/kurtosis/benchmark/c/benchmark.c

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,31 @@
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/chisquare/kurtosis.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 "chisquare-kurtosis"
2828
#define ITERATIONS 1000000
2929
#define REPEATS 3
3030

31+
/**
32+
* Prints the TAP version.
33+
*/
3134
static void print_version( void ) {
3235
printf( "TAP version 13\n" );
3336
}
3437

38+
/**
39+
* Prints the TAP summary.
40+
*
41+
* @param total total number of tests
42+
* @param passing total number of passing tests
43+
*/
3544
static void print_summary( int total, int passing ) {
3645
printf( "#\n" );
3746
printf( "1..%d\n", total ); // TAP plan
@@ -41,6 +50,11 @@ static void print_summary( int total, int passing ) {
4150
printf( "# ok\n" );
4251
}
4352

53+
/**
54+
* Prints benchmarks results.
55+
*
56+
* @param elapsed elapsed time in seconds
57+
*/
4458
static void print_results( double elapsed ) {
4559
double rate = (double)ITERATIONS / elapsed;
4660
printf( " ---\n" );
@@ -50,26 +64,43 @@ static void print_results( double elapsed ) {
5064
printf( " ...\n" );
5165
}
5266

67+
/**
68+
* Returns a clock time.
69+
*
70+
* @return clock time
71+
*/
5372
static double tic( void ) {
5473
struct timeval now;
5574
gettimeofday( &now, NULL );
56-
return (double)now.tv_sec + (double)now.tv_usec / 1.0e6;
75+
return (double)now.tv_sec + (double)now.tv_usec/1.0e6;
5776
}
5877

78+
/**
79+
* Generates a random number on the interval [min,max).
80+
*
81+
* @param min minimum value (inclusive)
82+
* @param max maximum value (exclusive)
83+
* @return random number
84+
*/
5985
static double random_uniform( const double min, const double max ) {
6086
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
61-
return min + ( v * ( max - min ) );
87+
return min + ( v*(max-min) );
6288
}
6389

90+
/**
91+
* Runs a benchmark.
92+
*
93+
* @return elapsed time in seconds
94+
*/
6495
static double benchmark( void ) {
65-
double elapsed;
6696
double k[ 100 ];
67-
double y;
97+
double elapsed;
6898
double start;
99+
double y;
69100
int i;
70101

71102
for ( i = 0; i < 100; i++ ) {
72-
k[ i ] = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 10.0 );
103+
k[ i ] = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 20.0 );
73104
}
74105

75106
start = tic();
@@ -88,11 +119,14 @@ static double benchmark( void ) {
88119
return elapsed;
89120
}
90121

122+
/**
123+
* Main execution sequence.
124+
*/
91125
int main( void ) {
92126
double elapsed;
93127
int i;
94128

95-
// Seed the random number generator:
129+
// Use the current time to seed the random number generator:
96130
srand( time( NULL ) );
97131

98132
print_version();

lib/node_modules/@stdlib/stats/base/dists/chisquare/kurtosis/examples/c/example.c

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

1919
#include "stdlib/stats/base/dists/chisquare/kurtosis.h"
20-
#include <stdio.h>
2120
#include <stdlib.h>
21+
#include <stdio.h>
2222

2323
static double random_uniform( const double min, const double max ) {
2424
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
@@ -31,7 +31,7 @@ int main( void ) {
3131
int i;
3232

3333
for ( i = 0; i < 10; i++ ) {
34-
k = random_uniform( 0.1, 10.0 ); // Ensure `k` is positive
34+
k = random_uniform( 1.0, 10.0 );
3535
result = stdlib_base_dists_chisquare_kurtosis( k );
3636
printf( "k: %lf, Kurt(X,k): %lf \n", k, result );
3737
}

lib/node_modules/@stdlib/stats/base/dists/chisquare/kurtosis/include/stdlib/stats/base/dists/chisquare/kurtosis.h

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

2929
/**
3030
* Returns the excess kurtosis of a chi-squared distribution.
31-
*
32-
* @param k degrees of freedom (must be positive)
33-
* @return excess kurtosis
3431
*/
3532
double stdlib_base_dists_chisquare_kurtosis( const double k );
3633

lib/node_modules/@stdlib/stats/base/dists/chisquare/kurtosis/src/addon.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/napi/unary.h"
2019
#include "stdlib/stats/base/dists/chisquare/kurtosis.h"
20+
#include "stdlib/math/base/napi/unary.h"
2121

2222
// cppcheck-suppress shadowFunction
2323
STDLIB_MATH_BASE_NAPI_MODULE_D_D( stdlib_base_dists_chisquare_kurtosis )

lib/node_modules/@stdlib/stats/base/dists/chisquare/kurtosis/src/main.c

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

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

2222
/**
2323
* Returns the excess kurtosis of a chi-squared distribution.
2424
*
25-
* @param k: PositiveNumber - degrees of freedom
26-
* @return PositiveNumber - excess kurtosis
25+
* @param k degrees of freedom
26+
* @return excess kurtosis
2727
*
2828
* @example
2929
* double v = stdlib_base_dists_chisquare_kurtosis( 9.0 );

0 commit comments

Comments
 (0)