Skip to content

Commit 94505e5

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: 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: 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 2cc83ca commit 94505e5

File tree

7 files changed

+36
-55
lines changed

7 files changed

+36
-55
lines changed

lib/node_modules/@stdlib/stats/base/dists/weibull/mgf/README.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ for ( i = 0; i < 10; i++ ) {
188188

189189
#### stdlib_base_dists_weibull_mgf( t, k, lambda )
190190

191-
Evaluates the mgf for an weibull distribution.
191+
Evaluates the [moment-generating function][mgf] (MGF) for a [Weibull][weibull-distribution] distribution with [shape parameter][shape] `k` and [scale parameter][scale] `lambda`.
192192

193193
```c
194194
double out = stdlib_base_dists_weibull_mgf( 1.0, 1.0, 0.5 );
@@ -197,7 +197,7 @@ double out = stdlib_base_dists_weibull_mgf( 1.0, 1.0, 0.5 );
197197

198198
The function accepts the following arguments:
199199

200-
- **t**: `[in] double` shape parameter.
200+
- **t**: `[in] double` input value.
201201
- **k**: `[in] double` shape parameter.
202202
- **λ**: `[in] double` scale parameter.
203203

@@ -206,35 +206,47 @@ double stdlib_base_dists_weibull_mgf( const double t, const double k, const doub
206206
```
207207
208208
</section>
209+
209210
<!-- /.usage -->
211+
210212
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
213+
211214
<section class="notes">
215+
212216
</section>
217+
213218
<!-- /.notes -->
219+
214220
<!-- C API usage examples. -->
221+
215222
<section class="examples">
223+
216224
### Examples
225+
217226
```c
218227
#include "stdlib/stats/base/dists/weibull/mgf.h"
219228
#include "stdlib/constants/float64/eps.h"
220229
#include <stdlib.h>
221230
#include <stdio.h>
231+
222232
static double random_uniform( const double min, const double max ) {
223233
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
224234
return min + ( v*(max-min) );
225235
}
236+
226237
int main( void ) {
227238
double lambda;
228239
double k;
229240
double t;
230241
double y;
231242
int i;
243+
232244
for ( i = 0; i < 25; i++ ) {
233-
t = random_uniform( 0.0, 10.0 ) + STDLIB_CONSTANT_FLOAT64_EPS;
234-
k = random_uniform( 0.0, 10.0 ) + STDLIB_CONSTANT_FLOAT64_EPS;
235-
lambda = random_uniform( 0.0, 10.0 ) + STDLIB_CONSTANT_FLOAT64_EPS;
245+
t = random_uniform( 0.0, 5.0 );
246+
k = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 10.0 );
247+
lambda = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 10.0 );
236248
y = stdlib_base_dists_weibull_mgf( t, k, lambda );
237-
printf( "t: %lf, k: %lf, λ: %lf, E(X;k,λ): %lf\n", t, k, lambda, y );
249+
printf( "t: %lf, k: %lf, λ: %lf, M_X(t;k,λ): %lf\n", t, k, lambda, y );
238250
}
239251
}
240252
```

lib/node_modules/@stdlib/stats/base/dists/weibull/mgf/benchmark/benchmark.native.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench' );
2525
var Float64Array = require( '@stdlib/array/float64' );
2626
var tryRequire = require( '@stdlib/utils/try-require' );
27-
var randu = require( '@stdlib/random/base/randu' );
27+
var uniform = require( '@stdlib/random/base/uniform' );
2828
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2929
var EPS = require( '@stdlib/constants/float64/eps' );
3030
var pkg = require( './../package.json' ).name;
@@ -53,9 +53,9 @@ bench( pkg, opts, function benchmark( b ) {
5353
t = new Float64Array( len );
5454
lambda = new Float64Array( len );
5555
for ( i = 0; i < len; i++ ) {
56-
t[ i ] = ( randu() * 10.0 ) + EPS;
57-
k[ i ] = ( randu() * 10.0 ) + EPS;
58-
lambda[ i ] = ( randu() * 10.0 ) + EPS;
56+
t[ i ] = uniform( 0.0, 5.0 );
57+
k[ i ] = uniform( EPS, 10.0 );
58+
lambda[ i ] = uniform( EPS, 10.0 );
5959
}
6060

6161
b.tic();

lib/node_modules/@stdlib/stats/base/dists/weibull/mgf/benchmark/c/benchmark.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ static double benchmark( void ) {
102102
int i;
103103

104104
for ( i = 0; i < 100; i++ ) {
105-
lambda[ i ] = random_uniform( 0.0, 1.0 ) + STDLIB_CONSTANT_FLOAT64_EPS;
106-
k[ i ] = random_uniform( 0.0, 1.0 ) + STDLIB_CONSTANT_FLOAT64_EPS;
107-
s[ i ] = random_uniform( 0.0, 1.0 ) + STDLIB_CONSTANT_FLOAT64_EPS;
105+
lambda[ i ] = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 10.0 );
106+
k[ i ] = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 10.0 );
107+
s[ i ] = random_uniform( 0.0, 5.0 );
108108
}
109109

110110
t = tic();

lib/node_modules/@stdlib/stats/base/dists/weibull/mgf/examples/c/example.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ int main( void ) {
3434
int i;
3535

3636
for ( i = 0; i < 25; i++ ) {
37-
t = random_uniform( 0.0, 10.0 ) + STDLIB_CONSTANT_FLOAT64_EPS;
38-
k = random_uniform( 0.0, 10.0 ) + STDLIB_CONSTANT_FLOAT64_EPS;
39-
lambda = random_uniform( 0.0, 10.0 ) + STDLIB_CONSTANT_FLOAT64_EPS;
37+
t = random_uniform( 0.0, 5.0 );
38+
k = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 10.0 );
39+
lambda = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 10.0 );
4040
y = stdlib_base_dists_weibull_mgf( t, k, lambda );
41-
printf( "t: %lf, k: %lf, λ: %lf, MGF(X;t,k,λ): %lf\n", t, k, lambda, y );
41+
printf( "t: %lf, k: %lf, λ: %lf, M_X(t;k,λ): %lf\n", t, k, lambda, y );
4242
}
4343
}

lib/node_modules/@stdlib/stats/base/dists/weibull/mgf/include/stdlib/stats/base/dists/weibull/mgf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ extern "C" {
2727
#endif
2828

2929
/**
30-
* Returns the mgf of an weibull distribution.
30+
* Evaluates the mgf of a Weibull distribution.
3131
*/
3232
double stdlib_base_dists_weibull_mgf( const double t, const double k, const double lambda );
3333

lib/node_modules/@stdlib/stats/base/dists/weibull/mgf/lib/native.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ var addon = require( './../src/addon.node' );
2828
/**
2929
* Evaluates the moment-generating function (MGF) for a Weibull distribution with shape `k` and scale `lambda` at a value `t`.
3030
*
31+
* @private
3132
* @param {number} t - input value
3233
* @param {PositiveNumber} k - shape parameter
3334
* @param {PositiveNumber} lambda - scale parameter

lib/node_modules/@stdlib/stats/base/dists/weibull/mgf/src/main.c

Lines changed: 5 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -26,46 +26,14 @@
2626
/**
2727
* Evaluates the moment-generating function (MGF) for a Weibull distribution with shape `k` and scale `lambda` at a value `t`.
2828
*
29-
* @param {number} t - input value
30-
* @param {PositiveNumber} k - shape parameter
31-
* @param {PositiveNumber} lambda - scale parameter
32-
* @returns {number} evaluated MGF
29+
* @param t input value
30+
* @param k shape parameter
31+
* @param lambda scale parameter
32+
* @return evaluated MGF
3333
*
3434
* @example
3535
* double y = stdlib_base_dists_weibull_mgf( 1.0, 1.0, 0.5 );
3636
* // returns ~2.0
37-
*
38-
* @example
39-
* double y = stdlib_base_dists_weibull_mgf( -1.0, 4.0, 4.0 );
40-
* // returns ~0.019
41-
*
42-
* @example
43-
* double y = stdlib_base_dists_weibull_mgf( NaN, 1.0, 1.0 );
44-
* // returns NaN
45-
*
46-
* @example
47-
* double y = stdlib_base_dists_weibull_mgf( 0.0, NaN, 1.0 );
48-
* // returns NaN
49-
*
50-
* @example
51-
* double y = stdlib_base_dists_weibull_mgf( 0.0, 1.0, NaN );
52-
* // returns NaN
53-
*
54-
* @example
55-
* double y = stdlib_base_dists_weibull_mgf( 0.2, -1.0, 0.5 );
56-
* // returns NaN
57-
*
58-
* @example
59-
* double y = stdlib_base_dists_weibull_mgf( 0.2, 0.0, 0.5 );
60-
* // returns NaN
61-
*
62-
* @example
63-
* double y = stdlib_base_dists_weibull_mgf( 0.2, 0.5, -1.0 );
64-
* // returns NaN
65-
*
66-
* @example
67-
* double y = stdlib_base_dists_weibull_mgf( 0.2, 0.5, 0.0 );
68-
* // returns NaN
6937
*/
7038
double stdlib_base_dists_weibull_mgf( const double t, const double k, const double lambda ) {
7139
double summand;
@@ -79,7 +47,7 @@ double stdlib_base_dists_weibull_mgf( const double t, const double k, const doub
7947
stdlib_base_is_nan( lambda ) ||
8048
k <= 0.0 ||
8149
lambda <= 0.0
82-
) {
50+
) {
8351
return 0.0 / 0.0; // NaN
8452
}
8553
sum = 1.0;

0 commit comments

Comments
 (0)