Skip to content

Commit 19175c6

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: na - 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: 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 475423e commit 19175c6

File tree

10 files changed

+98
-39
lines changed

10 files changed

+98
-39
lines changed

lib/node_modules/@stdlib/stats/base/dists/pareto-type1/mean/README.md

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

180180
#### stdlib_base_dists_pareto_type1_mean( alpha, beta )
181181

182-
Evaluates the mean for a Pareto Type I distribution.
182+
Returns the [expected value][expected-value] of a [Pareto (Type I)][pareto-distribution] distribution with parameters `alpha` (shape parameter) and `beta` (scale parameter).
183183

184184
```c
185185
double out = stdlib_base_dists_pareto_type1_mean( 2.0, 1.0 );
@@ -230,10 +230,10 @@ int main( void ) {
230230
int i;
231231
232232
for ( i = 0; i < 25; i++ ) {
233-
alpha = random_uniform( 1.5, 5.0 ); // alpha must be > 1 for mean to be defined
233+
alpha = random_uniform( 1.5, 5.0 );
234234
beta = random_uniform( 1.0, 10.0 );
235235
y = stdlib_base_dists_pareto_type1_mean( alpha, beta );
236-
printf( "alpha: %lf, beta: %lf, mean: %lf\n", alpha, beta, y );
236+
printf( "α: %lf, β: %lf, E(X;α,β): %lf\n", alpha, beta, y );
237237
}
238238
}
239239
```

lib/node_modules/@stdlib/stats/base/dists/pareto-type1/mean/benchmark/benchmark.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench' );
24-
var Float64Array = require( '@stdlib/array/float64' );
25-
var uniform = require( '@stdlib/random/base/uniform' );
24+
var uniform = require( '@stdlib/random/array/uniform' );
2625
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2726
var pkg = require( './../package.json' ).name;
2827
var mean = require( './../lib' );

lib/node_modules/@stdlib/stats/base/dists/pareto-type1/mean/benchmark/benchmark.native.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ bench( pkg + '::native', opts, function benchmark( b ) {
4646
var i;
4747

4848
len = 100;
49-
alpha = uniform( len, 1.5, 5.0 ); // alpha must be > 1 for mean to be defined
49+
alpha = uniform( len, 1.5, 5.0 );
5050
beta = uniform( len, 1.0, 10.0 );
5151

5252
b.tic();

lib/node_modules/@stdlib/stats/base/dists/pareto-type1/mean/benchmark/c/benchmark.c

Lines changed: 2 additions & 2 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>
2019
#include "stdlib/stats/base/dists/pareto-type1/mean.h"
2120
#include <math.h>
2221
#include <stdio.h>
2322
#include <stdlib.h>
2423
#include <time.h>
24+
#include <sys/time.h>
2525

2626
#define NAME "pareto-type1-mean"
2727
#define ITERATIONS 1000000
@@ -100,7 +100,7 @@ static double benchmark( void ) {
100100
int i;
101101

102102
for ( i = 0; i < 100; i++ ) {
103-
alpha[ i ] = random_uniform( 1.5, 5.0 ); // alpha must be > 1 for mean to be defined
103+
alpha[ i ] = random_uniform( 1.5, 5.0 );
104104
beta[ i ] = random_uniform( 1.0, 10.0 );
105105
}
106106

lib/node_modules/@stdlib/stats/base/dists/pareto-type1/mean/examples/c/example.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ int main( void ) {
3232
int i;
3333

3434
for ( i = 0; i < 25; i++ ) {
35-
alpha = random_uniform( 1.5, 5.0 ); // alpha must be > 1 for mean to be defined
35+
alpha = random_uniform( 1.5, 5.0 );
3636
beta = random_uniform( 1.0, 10.0 );
3737
y = stdlib_base_dists_pareto_type1_mean( alpha, beta );
38-
printf( "alpha: %lf, beta: %lf, mean: %lf\n", alpha, beta, y );
38+
printf( "α: %lf, β: %lf, E(X;α,β): %lf\n", alpha, beta, y );
3939
}
4040
}

lib/node_modules/@stdlib/stats/base/dists/pareto-type1/mean/include/stdlib/stats/base/dists/pareto-type1/mean.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 mean for a Pareto Type I distribution with shape parameter `alpha` and scale parameter `beta`.
30+
* Returns the expected value of a Pareto Type I distribution with shape parameter `alpha` and scale parameter `beta`.
3131
*/
3232
double stdlib_base_dists_pareto_type1_mean( const double alpha, const double beta );
3333

lib/node_modules/@stdlib/stats/base/dists/pareto-type1/mean/manifest.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
"libpath": [],
4040
"dependencies": [
4141
"@stdlib/math/base/napi/binary",
42-
"@stdlib/math/base/assert/is-nan"
42+
"@stdlib/math/base/assert/is-nan",
43+
"@stdlib/constants/float64/pinf"
4344
]
4445
},
4546
{
@@ -54,7 +55,8 @@
5455
"libraries": [],
5556
"libpath": [],
5657
"dependencies": [
57-
"@stdlib/math/base/assert/is-nan"
58+
"@stdlib/math/base/assert/is-nan",
59+
"@stdlib/constants/float64/pinf"
5860
]
5961
},
6062
{
@@ -69,7 +71,8 @@
6971
"libraries": [],
7072
"libpath": [],
7173
"dependencies": [
72-
"@stdlib/math/base/assert/is-nan"
74+
"@stdlib/math/base/assert/is-nan",
75+
"@stdlib/constants/float64/pinf"
7376
]
7477
}
7578
]

lib/node_modules/@stdlib/stats/base/dists/pareto-type1/mean/src/main.c

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

19-
#include "stdlib/math/base/assert/is_nan.h"
2019
#include "stdlib/stats/base/dists/pareto-type1/mean.h"
20+
#include "stdlib/math/base/assert/is_nan.h"
21+
#include "stdlib/constants/float64/pinf.h"
2122

2223
/**
23-
* Evaluates the mean for a Pareto Type I distribution with shape parameter `alpha` and scale parameter `beta`.
24+
* Returns the expected value for a Pareto Type I distribution with shape parameter `alpha` and scale parameter `beta`.
2425
*
2526
* @param alpha shape parameter
2627
* @param beta scale parameter
27-
* @return evaluated mean
28+
* @return expected value
2829
*
2930
* @example
3031
* double y = stdlib_base_dists_pareto_type1_mean( 2.0, 1.0 );
@@ -35,7 +36,7 @@ double stdlib_base_dists_pareto_type1_mean( const double alpha, const double bet
3536
return 0.0 / 0.0; // NaN
3637
}
3738
if ( alpha <= 1.0 ) {
38-
return 1.0 / 0.0; // +Infinity
39+
return STDLIB_CONSTANT_FLOAT64_PINF;
3940
}
4041
return ( alpha * beta ) / ( alpha - 1.0 );
4142
}

lib/node_modules/@stdlib/stats/base/dists/pareto-type1/mean/test/test.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ tape( 'main export is a function', function test( t ) {
4444

4545
tape( 'if provided `NaN` for any parameter, the function returns `NaN`', function test( t ) {
4646
var v = mean( NaN, 0.5 );
47-
t.equal( isnan( v ), true, 'returns NaN' );
47+
t.equal( isnan( v ), true, 'returns expected value' );
4848

4949
v = mean( 10.0, NaN );
50-
t.equal( isnan( v ), true, 'returns NaN' );
50+
t.equal( isnan( v ), true, 'returns expected value' );
5151

5252
t.end();
5353
});
@@ -56,19 +56,19 @@ tape( 'if provided `alpha <= 0`, the function returns `NaN`', function test( t )
5656
var y;
5757

5858
y = mean( -1.0, 2.0 );
59-
t.equal( isnan( y ), true, 'returns NaN' );
59+
t.equal( isnan( y ), true, 'returns expected value' );
6060

6161
y = mean( NINF, 1.0 );
62-
t.equal( isnan( y ), true, 'returns NaN' );
62+
t.equal( isnan( y ), true, 'returns expected value' );
6363

6464
y = mean( NINF, PINF );
65-
t.equal( isnan( y ), true, 'returns NaN' );
65+
t.equal( isnan( y ), true, 'returns expected value' );
6666

6767
y = mean( NINF, NINF );
68-
t.equal( isnan( y ), true, 'returns NaN' );
68+
t.equal( isnan( y ), true, 'returns expected value' );
6969

7070
y = mean( NINF, NaN );
71-
t.equal( isnan( y ), true, 'returns NaN' );
71+
t.equal( isnan( y ), true, 'returns expected value' );
7272

7373
t.end();
7474
});
@@ -77,13 +77,13 @@ tape( 'if provided `0 < alpha <= 1`, the function returns `+Infinity`', function
7777
var y;
7878

7979
y = mean( 0.2, 2.0 );
80-
t.equal( y, PINF, 'returns +Infinity' );
80+
t.equal( y, PINF, 'returns expected value' );
8181

8282
y = mean( 0.5, 2.0 );
83-
t.equal( y, PINF, 'returns +Infinity' );
83+
t.equal( y, PINF, 'returns expected value' );
8484

8585
y = mean( 0.9, 2.0 );
86-
t.equal( y, PINF, 'returns +Infinity' );
86+
t.equal( y, PINF, 'returns expected value' );
8787

8888
t.end();
8989
});
@@ -92,19 +92,19 @@ tape( 'if provided `beta <= 0`, the function returns `NaN`', function test( t )
9292
var y;
9393

9494
y = mean( 2.0, -1.0 );
95-
t.equal( isnan( y ), true, 'returns NaN' );
95+
t.equal( isnan( y ), true, 'returns expected value' );
9696

9797
y = mean( 1.0, NINF );
98-
t.equal( isnan( y ), true, 'returns NaN' );
98+
t.equal( isnan( y ), true, 'returns expected value' );
9999

100100
y = mean( PINF, NINF );
101-
t.equal( isnan( y ), true, 'returns NaN' );
101+
t.equal( isnan( y ), true, 'returns expected value' );
102102

103103
y = mean( NINF, NINF );
104-
t.equal( isnan( y ), true, 'returns NaN' );
104+
t.equal( isnan( y ), true, 'returns expected value' );
105105

106106
y = mean( NaN, NINF );
107-
t.equal( isnan( y ), true, 'returns NaN' );
107+
t.equal( isnan( y ), true, 'returns expected value' );
108108

109109
t.end();
110110
});

lib/node_modules/@stdlib/stats/base/dists/pareto-type1/mean/test/test.native.js

Lines changed: 62 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ var tape = require( 'tape' );
2525
var tryRequire = require( '@stdlib/utils/try-require' );
2626
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2727
var abs = require( '@stdlib/math/base/special/abs' );
28+
var PINF = require( '@stdlib/constants/float64/pinf' );
29+
var NINF = require( '@stdlib/constants/float64/ninf' );
2830
var EPS = require( '@stdlib/constants/float64/eps' );
2931

3032

@@ -51,20 +53,74 @@ tape( 'main export is a function', opts, function test( t ) {
5153

5254
tape( 'if provided `NaN` for any parameter, the function returns `NaN`', opts, function test( t ) {
5355
var y = mean( NaN, 1.0 );
54-
t.equal( isnan( y ), true, 'returns NaN' );
56+
t.equal( isnan( y ), true, 'returns expected value' );
5557
y = mean( 2.0, NaN );
56-
t.equal( isnan( y ), true, 'returns NaN' );
58+
t.equal( isnan( y ), true, 'returns expected value' );
5759
t.end();
5860
});
5961

60-
tape( 'if provided `alpha <= 1`, the function returns `NaN`', opts, function test( t ) {
62+
tape( 'if provided `alpha <= 0`, the function returns `NaN`', opts, function test( t ) {
6163
var y;
6264

65+
y = mean( -1.0, 2.0 );
66+
t.equal( isnan( y ), true, 'returns expected value' );
67+
68+
y = mean( 0.0, 1.0 );
69+
t.equal( isnan( y ), true, 'returns expected value' );
70+
71+
y = mean( NINF, 1.0 );
72+
t.equal( isnan( y ), true, 'returns expected value' );
73+
74+
y = mean( NINF, PINF );
75+
t.equal( isnan( y ), true, 'returns expected value' );
76+
77+
y = mean( NINF, NINF );
78+
t.equal( isnan( y ), true, 'returns expected value' );
79+
80+
y = mean( NINF, NaN );
81+
t.equal( isnan( y ), true, 'returns expected value' );
82+
83+
t.end();
84+
});
85+
86+
tape( 'if provided `0 < alpha <= 1`, the function returns `+Infinity`', opts, function test( t ) {
87+
var y;
88+
89+
y = mean( 0.2, 2.0 );
90+
t.equal( y, PINF, 'returns expected value' );
91+
92+
y = mean( 0.5, 2.0 );
93+
t.equal( y, PINF, 'returns expected value' );
94+
95+
y = mean( 0.9, 2.0 );
96+
t.equal( y, PINF, 'returns expected value' );
97+
6398
y = mean( 1.0, 1.0 );
64-
t.equal( isnan( y ), true, 'returns NaN' );
99+
t.equal( y, PINF, 'returns expected value' );
100+
101+
t.end();
102+
});
103+
104+
tape( 'if provided `beta <= 0`, the function returns `NaN`', opts, function test( t ) {
105+
var y;
106+
107+
y = mean( 2.0, -1.0 );
108+
t.equal( isnan( y ), true, 'returns expected value' );
109+
110+
y = mean( 2.0, 0.0 );
111+
t.equal( isnan( y ), true, 'returns expected value' );
112+
113+
y = mean( 1.0, NINF );
114+
t.equal( isnan( y ), true, 'returns expected value' );
115+
116+
y = mean( PINF, NINF );
117+
t.equal( isnan( y ), true, 'returns expected value' );
118+
119+
y = mean( NINF, NINF );
120+
t.equal( isnan( y ), true, 'returns expected value' );
65121

66-
y = mean( 0.5, 1.0 );
67-
t.equal( isnan( y ), true, 'returns NaN' );
122+
y = mean( NaN, NINF );
123+
t.equal( isnan( y ), true, 'returns expected value' );
68124

69125
t.end();
70126
});

0 commit comments

Comments
 (0)