Skip to content

Commit 3abedb2

Browse files
fix: using int32_t instead of double for k
--- 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: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - 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 ---
1 parent 9f36c96 commit 3abedb2

File tree

10 files changed

+30
-38
lines changed

10 files changed

+30
-38
lines changed

lib/node_modules/@stdlib/stats/base/dists/erlang/stdev/README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,11 @@ double out = stdlib_base_dists_erlang_stdev( 1, 1.0 );
182182

183183
The function accepts the following arguments:
184184

185-
- **k**: `[in] double` shape parameter.
185+
- **k**: `[in] int32_t` shape parameter.
186186
- **lambda**: `[in] double` rate parameter.
187187

188188
```c
189-
double stdlib_base_dists_erlang_stdev( const double k, const double lambda );
189+
double stdlib_base_dists_erlang_stdev( const int32_t k, const double lambda );
190190
```
191191
192192
</section>
@@ -211,6 +211,7 @@ double stdlib_base_dists_erlang_stdev( const double k, const double lambda );
211211
#include "stdlib/stats/base/dists/erlang/stdev.h"
212212
#include "stdlib/constants/float64/eps.h"
213213
#include "stdlib/math/base/special/round.h"
214+
#include <stdint.h>
214215
#include <stdlib.h>
215216
#include <stdio.h>
216217
@@ -221,15 +222,15 @@ static double random_uniform( const double min, const double max ) {
221222
222223
int main( void ) {
223224
double lambda;
224-
double k;
225+
int32_t k;
225226
double y;
226227
int i;
227228
228229
for ( i = 0; i < 25; i++ ) {
229-
k = stdlib_base_round(random_uniform( 0.0, 10.0 ));
230-
lambda = random_uniform( 0.0, 10.0 ) + STDLIB_CONSTANT_FLOAT64_EPS;
230+
k = stdlib_base_round( random_uniform( 0.0, 10.0 ) );
231+
lambda = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 10.0 );
231232
y = stdlib_base_dists_erlang_stdev( k, lambda );
232-
printf( "k: %lf, λ: %lf, SD(X;k,λ): %lf\n", k, lambda, y );
233+
printf( "k: %d, λ: %lf, SD(X;k,λ): %lf\n", k, lambda, y );
233234
}
234235
}
235236
```

lib/node_modules/@stdlib/stats/base/dists/erlang/stdev/benchmark/benchmark.native.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@
2222

2323
var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench' );
25+
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' );
26+
var uniform = require( '@stdlib/random/base/uniform' );
2527
var Float64Array = require( '@stdlib/array/float64' );
26-
var randu = require( '@stdlib/random/base/randu' );
27-
var ceil = require( '@stdlib/math/base/special/ceil' );
28+
var Int32Array = require( '@stdlib/array/int32' );
2829
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2930
var EPS = require( '@stdlib/constants/float64/eps' );
3031
var tryRequire = require( '@stdlib/utils/try-require' );
@@ -49,11 +50,11 @@ bench( pkg+'::native', opts, function benchmark( b ) {
4950
var i;
5051

5152
len = 100;
52-
k = new Float64Array( len );
53+
k = new Int32Array( len );
5354
lambda = new Float64Array( len );
5455
for ( i = 0; i < len; i++ ) {
55-
k[ i ] = ceil( randu()*10.0 );
56-
lambda[ i ] = ( randu()*10.0 ) + EPS;
56+
k[ i ] = discreteUniform( 1, 10 );
57+
lambda[ i ] = uniform( EPS, 10.0 );
5758
}
5859

5960
b.tic();

lib/node_modules/@stdlib/stats/base/dists/erlang/stdev/benchmark/c/benchmark.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "stdlib/stats/base/dists/erlang/stdev.h"
2020
#include "stdlib/math/base/special/ceil.h"
2121
#include "stdlib/constants/float64/eps.h"
22+
#include <stdint.h>
2223
#include <stdlib.h>
2324
#include <stdio.h>
2425
#include <math.h>
@@ -96,14 +97,14 @@ static double random_uniform( const double min, const double max ) {
9697
static double benchmark( void ) {
9798
double elapsed;
9899
double lambda[ 100 ];
99-
double k[ 100 ];
100+
int32_t k[ 100 ];
100101
double y;
101102
double t;
102103
int i;
103104

104105
for ( i = 0; i < 100; i++ ) {
105-
k[ i ] = stdlib_base_ceil(random_uniform( 0.0, 10.0 ));
106-
lambda[ i ] = random_uniform( 0.0, 10.0 ) + STDLIB_CONSTANT_FLOAT64_EPS;
106+
lambda[ i ] = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 10.0 );
107+
k[ i ] = stdlib_base_ceil(random_uniform( 1.0, 10.0 ));
107108
}
108109

109110
t = tic();

lib/node_modules/@stdlib/stats/base/dists/erlang/stdev/examples/c/example.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "stdlib/stats/base/dists/erlang/stdev.h"
2020
#include "stdlib/constants/float64/eps.h"
2121
#include "stdlib/math/base/special/round.h"
22+
#include <stdint.h>
2223
#include <stdlib.h>
2324
#include <stdio.h>
2425

@@ -29,14 +30,14 @@ static double random_uniform( const double min, const double max ) {
2930

3031
int main( void ) {
3132
double lambda;
32-
double k;
33+
int32_t k;
3334
double y;
3435
int i;
3536

3637
for ( i = 0; i < 25; i++ ) {
37-
k = stdlib_base_round(random_uniform( 0.0, 10.0 ));
38-
lambda = random_uniform( 0.0, 10.0 ) + STDLIB_CONSTANT_FLOAT64_EPS;
38+
k = stdlib_base_round( random_uniform( 0.0, 10.0 ) );
39+
lambda = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 10.0 );
3940
y = stdlib_base_dists_erlang_stdev( k, lambda );
40-
printf( "k: %lf, λ: %lf, SD(X;k,λ): %lf\n", k, lambda, y );
41+
printf( "k: %d, λ: %lf, SD(X;k,λ): %lf\n", k, lambda, y );
4142
}
4243
}

lib/node_modules/@stdlib/stats/base/dists/erlang/stdev/include/stdlib/stats/base/dists/erlang/stdev.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#ifndef STDLIB_STATS_BASE_DISTS_ERLANG_STDEV_H
2020
#define STDLIB_STATS_BASE_DISTS_ERLANG_STDEV_H
2121

22+
#include <stdint.h>
23+
2224
/*
2325
* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler.
2426
*/
@@ -29,7 +31,7 @@ extern "C" {
2931
/**
3032
* Returns the standard deviation of an Erlang distribution.
3133
*/
32-
double stdlib_base_dists_erlang_stdev( const double k, const double lambda );
34+
double stdlib_base_dists_erlang_stdev( const int32_t k, const double lambda );
3335

3436
#ifdef __cplusplus
3537
}

lib/node_modules/@stdlib/stats/base/dists/erlang/stdev/lib/native.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@ var addon = require( './../src/addon.node' );
4646
* // returns ~1.414
4747
*
4848
* @example
49-
* var v = stdev( 1.5, 2.0 );
50-
* // returns NaN
51-
*
52-
* @example
5349
* var v = stdev( 1, -0.1 );
5450
* // returns NaN
5551
*

lib/node_modules/@stdlib/stats/base/dists/erlang/stdev/manifest.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
"dependencies": [
4141
"@stdlib/math/base/napi/binary",
4242
"@stdlib/math/base/assert/is-nan",
43-
"@stdlib/math/base/assert/is-positive-integer",
4443
"@stdlib/math/base/special/sqrt"
4544
]
4645
},
@@ -57,7 +56,6 @@
5756
"libpath": [],
5857
"dependencies": [
5958
"@stdlib/math/base/assert/is-nan",
60-
"@stdlib/math/base/assert/is-positive-integer",
6159
"@stdlib/math/base/special/sqrt",
6260
"@stdlib/constants/float64/eps",
6361
"@stdlib/math/base/special/ceil"
@@ -76,7 +74,6 @@
7674
"libpath": [],
7775
"dependencies": [
7876
"@stdlib/math/base/assert/is-nan",
79-
"@stdlib/math/base/assert/is-positive-integer",
8077
"@stdlib/math/base/special/sqrt",
8178
"@stdlib/constants/float64/eps",
8279
"@stdlib/math/base/special/round"

lib/node_modules/@stdlib/stats/base/dists/erlang/stdev/src/addon.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@
2020
#include "stdlib/math/base/napi/binary.h"
2121

2222
// cppcheck-suppress shadowFunction
23-
STDLIB_MATH_BASE_NAPI_MODULE_DD_D( stdlib_base_dists_erlang_stdev )
23+
STDLIB_MATH_BASE_NAPI_MODULE_ID_D( stdlib_base_dists_erlang_stdev )

lib/node_modules/@stdlib/stats/base/dists/erlang/stdev/src/main.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@
1717
*/
1818

1919
#include "stdlib/stats/base/dists/erlang/stdev.h"
20-
#include "stdlib/math/base/assert/is_positive_integer.h"
2120
#include "stdlib/math/base/assert/is_nan.h"
2221
#include "stdlib/math/base/special/sqrt.h"
23-
22+
#include <stdint.h>
2423

2524
/**
2625
* Returns the standard deviation of an Erlang distribution.
@@ -30,12 +29,12 @@
3029
* @return standard deviation
3130
*
3231
* @example
33-
* double y = stdlib_base_erlang_stdev( 1, 1.0 );
32+
* double y = stdlib_base_dists_erlang_stdev( 1, 1.0 );
3433
* // returns 1.0
3534
*/
36-
double stdlib_base_dists_erlang_stdev( const double k, const double lambda ) {
35+
double stdlib_base_dists_erlang_stdev( const int32_t k, const double lambda ) {
3736
if (
38-
!stdlib_base_is_positive_integer( k ) ||
37+
k <= 0.0 ||
3938
stdlib_base_is_nan( lambda ) ||
4039
lambda <= 0.0
4140
) {

lib/node_modules/@stdlib/stats/base/dists/erlang/stdev/test/test.native.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,6 @@ tape( 'if provided `NaN` for any parameter, the function returns `NaN`', opts, f
6464
tape( 'if provided a `k` that is not a positive integer, the function returns `NaN`', opts, function test( t ) {
6565
var y;
6666

67-
y = stdev( 1.5, 2.0 );
68-
t.equal( isnan( y ), true, 'returns NaN' );
69-
70-
y = stdev( 3.9, 2.0 );
71-
t.equal( isnan( y ), true, 'returns NaN' );
72-
7367
y = stdev( 0.0, 2.0 );
7468
t.equal( isnan( y ), true, 'returns NaN' );
7569

0 commit comments

Comments
 (0)