Skip to content

Commit 52afe52

Browse files
committed
refactor: apply suggestions from previous PRs
--- 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: passed - 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: missing_dependencies - task: lint_c_benchmarks status: missing_dependencies - 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: na - 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 753995a commit 52afe52

File tree

6 files changed

+159
-175
lines changed

6 files changed

+159
-175
lines changed

lib/node_modules/@stdlib/stats/base/dists/negative-binomial/mgf/README.md

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

205205
#### stdlib_base_negative_binomial_mgf( t, r, p )
206206

207-
Evaluates the moment-generating function (MGF) for a negative binomial distribution.ion function (CDF) for an arcsine distribution.
207+
Evaluates the [moment-generating function][mgf] for a [negative binomial][negative-binomial-distribution] distribution with number of successes until experiment is stopped `r` and success probability `p`.
208208

209209
```c
210210
double out = stdlib_base_negative_binomial_mgf( 0.05, 20.0, 0.8 );
@@ -258,10 +258,10 @@ int main( void ) {
258258
259259
for ( i = 0; i < 25; i++ ) {
260260
t = random_uniform( -1.0, 1.0 );
261-
r = random_uniform( 1.0, 10.0 ); // r must be positive
262-
p = random_uniform( 0.0, 1.0 ); // p must be between 0 and 1
261+
r = random_uniform( 1.0, 10.0 );
262+
p = random_uniform( 0.0, 1.0 );
263263
y = stdlib_base_negative_binomial_mgf( t, r, p );
264-
printf( "t: %lf, r: %lf, p: %lf, MGF(t;r,p): %lf\n", t, r, p, y );
264+
printf( "t: %lf, r: %lf, p: %lf, M_X(t;r,p): %lf\n", t, r, p, y );
265265
}
266266
267267
return 0;

lib/node_modules/@stdlib/stats/base/dists/negative-binomial/mgf/benchmark/c/benchmark.c

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

19+
#include <sys/time.h>
1920
#include "stdlib/stats/base/dists/negative-binomial/mgf.h"
20-
#include <stdlib.h>
21-
#include <stdio.h>
2221
#include <math.h>
22+
#include <stdio.h>
23+
#include <stdlib.h>
2324
#include <time.h>
24-
#include <sys/time.h>
2525

2626
#define NAME "negative-binomial-mgf"
2727
#define ITERATIONS 1000000
@@ -31,7 +31,7 @@
3131
* Prints the TAP version.
3232
*/
3333
static void print_version( void ) {
34-
printf( "TAP version 13\n" );
34+
printf( "TAP version 13\n" );
3535
}
3636

3737
/**
@@ -41,12 +41,12 @@ static void print_version( void ) {
4141
* @param passing total number of passing tests
4242
*/
4343
static void print_summary( int total, int passing ) {
44-
printf( "#\n" );
45-
printf( "1..%d\n", total ); // TAP plan
46-
printf( "# total %d\n", total );
47-
printf( "# pass %d\n", passing );
48-
printf( "#\n" );
49-
printf( "# ok\n" );
44+
printf( "#\n" );
45+
printf( "1..%d\n", total ); // TAP plan
46+
printf( "# total %d\n", total );
47+
printf( "# pass %d\n", passing );
48+
printf( "#\n" );
49+
printf( "# ok\n" );
5050
}
5151

5252
/**
@@ -55,12 +55,12 @@ static void print_summary( int total, int passing ) {
5555
* @param elapsed elapsed time in seconds
5656
*/
5757
static void print_results( double elapsed ) {
58-
double rate = (double)ITERATIONS / elapsed;
59-
printf( " ---\n" );
60-
printf( " iterations: %d\n", ITERATIONS );
61-
printf( " elapsed: %0.9f\n", elapsed );
62-
printf( " rate: %0.9f\n", rate );
63-
printf( " ...\n" );
58+
double rate = (double)ITERATIONS / elapsed;
59+
printf( " ---\n" );
60+
printf( " iterations: %d\n", ITERATIONS );
61+
printf( " elapsed: %0.9f\n", elapsed );
62+
printf( " rate: %0.9f\n", rate );
63+
printf( " ...\n" );
6464
}
6565

6666
/**
@@ -69,9 +69,9 @@ static void print_results( double elapsed ) {
6969
* @return clock time
7070
*/
7171
static double tic( void ) {
72-
struct timeval now;
73-
gettimeofday( &now, NULL );
74-
return (double)now.tv_sec + (double)now.tv_usec/1.0e6;
72+
struct timeval now;
73+
gettimeofday( &now, NULL );
74+
return (double)now.tv_sec + (double)now.tv_usec / 1.0e6;
7575
}
7676

7777
/**
@@ -82,8 +82,8 @@ static double tic( void ) {
8282
* @return random number
8383
*/
8484
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) );
85+
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
86+
return min + ( v * ( max - min ) );
8787
}
8888

8989
/**
@@ -92,51 +92,51 @@ static double random_uniform( const double min, const double max ) {
9292
* @return elapsed time in seconds
9393
*/
9494
static double benchmark( void ) {
95-
double elapsed;
96-
double t[ 100 ];
97-
double r[ 100 ];
98-
double p[ 100 ];
99-
double y;
100-
double time;
101-
int i;
95+
double elapsed;
96+
double t[ 100 ];
97+
double r[ 100 ];
98+
double p[ 100 ];
99+
double y;
100+
double time;
101+
int i;
102102

103-
for ( i = 0; i < 100; i++ ) {
104-
t[ i ] = random_uniform( -2.0, 0.0 );
105-
r[ i ] = random_uniform( 1.0, 100.0 );
106-
p[ i ] = random_uniform( 0.1, 1.0 );
107-
}
103+
for ( i = 0; i < 100; i++ ) {
104+
t[ i ] = random_uniform( -2.0, 0.0 );
105+
r[ i ] = random_uniform( 1.0, 100.0 );
106+
p[ i ] = random_uniform( 0.1, 1.0 );
107+
}
108108

109-
time = tic();
110-
for ( i = 0; i < ITERATIONS; i++ ) {
111-
y = stdlib_base_negative_binomial_mgf( t[ i % 100 ], r[ i % 100 ], p[ i % 100 ] );
112-
if ( y != y ) {
113-
printf( "should not return NaN\n" );
114-
break;
115-
}
116-
}
117-
elapsed = tic() - time;
118-
if ( y != y ) {
119-
printf( "should not return NaN\n" );
120-
}
121-
return elapsed;
109+
time = tic();
110+
for ( i = 0; i < ITERATIONS; i++ ) {
111+
y = stdlib_base_negative_binomial_mgf( t[ i % 100 ], r[ i % 100 ], p[ i % 100 ] );
112+
if ( y != y ) {
113+
printf( "should not return NaN\n" );
114+
break;
115+
}
116+
}
117+
elapsed = tic() - time;
118+
if ( y != y ) {
119+
printf( "should not return NaN\n" );
120+
}
121+
return elapsed;
122122
}
123123

124124
/**
125125
* Main execution sequence.
126126
*/
127127
int main( void ) {
128-
double elapsed;
129-
int i;
128+
double elapsed;
129+
int i;
130130

131-
// Use the current time to seed the random number generator:
132-
srand( time( NULL ) );
131+
// Use the current time to seed the random number generator:
132+
srand( time( NULL ) );
133133

134-
print_version();
135-
for ( i = 0; i < REPEATS; i++ ) {
136-
printf( "# c::%s\n", NAME );
137-
elapsed = benchmark();
138-
print_results( elapsed );
139-
printf( "ok %d benchmark finished\n", i+1 );
140-
}
141-
print_summary( REPEATS, REPEATS );
134+
print_version();
135+
for ( i = 0; i < REPEATS; i++ ) {
136+
printf( "# c::%s\n", NAME );
137+
elapsed = benchmark();
138+
print_results( elapsed );
139+
printf( "ok %d benchmark finished\n", i + 1 );
140+
}
141+
print_summary( REPEATS, REPEATS );
142142
}
Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
11
/**
2-
* @license Apache-2.0
3-
*
4-
* Copyright (c) 2025 The Stdlib Authors.
5-
*
6-
* Licensed under the Apache License, Version 2.0 (the "License");
7-
* you may not use this file except in compliance with the License.
8-
* You may obtain a copy of the License at
9-
*
10-
* http://www.apache.org/licenses/LICENSE-2.0
11-
*
12-
* Unless required by applicable law or agreed to in writing, software
13-
* distributed under the License is distributed on an "AS IS" BASIS,
14-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15-
* See the License for the specific language governing permissions and
16-
* limitations under the License.
17-
*/
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
1818

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

2323
static double random_uniform( const double min, const double max ) {
24-
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
25-
return min + ( v * ( max - min ) );
24+
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
25+
return min + ( v * ( max - min ) );
2626
}
2727

2828
int main( void ) {
29-
double t;
30-
double r;
31-
double p;
32-
double y;
33-
int i;
29+
double t;
30+
double r;
31+
double p;
32+
double y;
33+
int i;
3434

35-
for ( i = 0; i < 25; i++ ) {
36-
t = random_uniform( -1.0, 1.0 );
37-
r = random_uniform( 1.0, 10.0 ); // r must be positive
38-
p = random_uniform( 0.0, 1.0 ); // p must be between 0 and 1
39-
y = stdlib_base_negative_binomial_mgf( t, r, p );
40-
printf( "t: %lf, r: %lf, p: %lf, MGF(t;r,p): %lf\n", t, r, p, y );
41-
}
35+
for ( i = 0; i < 25; i++ ) {
36+
t = random_uniform( -1.0, 1.0 );
37+
r = random_uniform( 1.0, 10.0 );
38+
p = random_uniform( 0.0, 1.0 );
39+
y = stdlib_base_negative_binomial_mgf( t, r, p );
40+
printf( "t: %lf, r: %lf, p: %lf, M_X(t;r,p): %lf\n", t, r, p, y );
41+
}
4242

43-
return 0;
43+
return 0;
4444
}

lib/node_modules/@stdlib/stats/base/dists/negative-binomial/mgf/include/stdlib/stats/base/dists/negative-binomial/mgf.h

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
/**
2-
* @license Apache-2.0
3-
*
4-
* Copyright (c) 2025 The Stdlib Authors.
5-
*
6-
* Licensed under the Apache License, Version 2.0 (the "License");
7-
* you may not use this file except in compliance with the License.
8-
* You may obtain a copy of the License at
9-
*
10-
* http://www.apache.org/licenses/LICENSE-2.0
11-
*
12-
* Unless required by applicable law or agreed to in writing, software
13-
* distributed under the License is distributed on an "AS IS" BASIS,
14-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15-
* See the License for the specific language governing permissions and
16-
* limitations under the License.
17-
*/
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
1818

1919
#ifndef STDLIB_STATS_BASE_DISTS_NEGATIVE_BINOMIAL_MGF_H
2020
#define STDLIB_STATS_BASE_DISTS_NEGATIVE_BINOMIAL_MGF_H

lib/node_modules/@stdlib/stats/base/dists/negative-binomial/mgf/src/addon.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
/**
2-
* @license Apache-2.0
3-
*
4-
* Copyright (c) 2025 The Stdlib Authors.
5-
*
6-
* Licensed under the Apache License, Version 2.0 (the "License");
7-
* you may not use this file except in compliance with the License.
8-
* You may obtain a copy of the License at
9-
*
10-
* http://www.apache.org/licenses/LICENSE-2.0
11-
*
12-
* Unless required by applicable law or agreed to in writing, software
13-
* distributed under the License is distributed on an "AS IS" BASIS,
14-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15-
* See the License for the specific language governing permissions and
16-
* limitations under the License.
17-
*/
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
1818

1919
#include "stdlib/stats/base/dists/negative-binomial/mgf.h"
2020
#include "stdlib/math/base/napi/ternary.h"

0 commit comments

Comments
 (0)