Skip to content

Commit 620504e

Browse files
committed
fix: update test and documents
--- 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: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: missing_dependencies - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 4f8f429 commit 620504e

5 files changed

Lines changed: 30 additions & 23 deletions

File tree

lib/node_modules/@stdlib/stats/base/dists/gilbrat/variance/README.md

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -124,22 +124,6 @@ logEachMap( 'σ: %lf, Var(X;σ): %lf', sigma, variance );
124124

125125
<!-- /.examples -->
126126

127-
<!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
128-
129-
<section class="references">
130-
131-
</section>
132-
133-
<!-- /.references -->
134-
135-
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
136-
137-
<section class="related">
138-
139-
</section>
140-
141-
<!-- /.related -->
142-
143127
<!-- Section for C API documentation. -->
144128

145129
* * *
@@ -225,6 +209,14 @@ int main( void ) {
225209

226210
<!-- /.c -->
227211

212+
<!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
213+
214+
<section class="references">
215+
216+
</section>
217+
218+
<!-- /.references -->
219+
228220
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
229221

230222
<section class="related">

lib/node_modules/@stdlib/stats/base/dists/gilbrat/variance/benchmark/c/benchmark.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ 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;
9695
double sigma[ 100 ];
96+
double elapsed;
9797
double y;
9898
double t;
9999
int i;

lib/node_modules/@stdlib/stats/base/dists/gilbrat/variance/lib/main.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' );
2424
var E = require( '@stdlib/constants/float64/e' );
2525

2626

27-
// VARIABLES //
28-
29-
var VARIANCE = E * ( E - 1.0 );
30-
31-
3227
// MAIN //
3328

3429
/**
@@ -50,10 +45,12 @@ var VARIANCE = E * ( E - 1.0 );
5045
* // returns NaN
5146
*/
5247
function variance( sigma ) {
48+
var variance;
5349
if ( isnan( sigma ) || sigma <= 0.0 ) {
5450
return NaN;
5551
}
56-
return VARIANCE;
52+
variance = E * ( E - 1.0 );
53+
return variance;
5754
}
5855

5956

lib/node_modules/@stdlib/stats/base/dists/gilbrat/variance/test/test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ tape( 'if provided `NaN` for `sigma`, the function returns `NaN`', function test
4444
t.end();
4545
});
4646

47+
tape( 'if provided non-positive value for `sigma`, the function returns `NaN`', function test( t ) {
48+
var y = variance( 0.0 );
49+
t.strictEqual( isnan( y ), true, 'returns expected value' );
50+
51+
y = variance( -1.0 );
52+
t.strictEqual( isnan( y ), true, 'returns expected value' );
53+
t.end();
54+
});
55+
4756
tape( 'the function returns the variance of a gilbrat distribution', function test( t ) {
4857
var expected;
4958
var sigma;

lib/node_modules/@stdlib/stats/base/dists/gilbrat/variance/test/test.native.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,15 @@ tape( 'if provided `NaN`, the function returns `NaN`', opts, function test( t )
5353
t.end();
5454
});
5555

56+
tape( 'if provided non-positive value for `sigma`, the function returns `NaN`', opts, function test( t ) {
57+
var y = variance( 0.0 );
58+
t.strictEqual( isnan( y ), true, 'returns expected value' );
59+
60+
y = variance( -1.0 );
61+
t.strictEqual( isnan( y ), true, 'returns expected value' );
62+
t.end();
63+
});
64+
5665
tape( 'the function returns the variance of a gilbrat distribution', opts, function test( t ) {
5766
var expected;
5867
var sigma;

0 commit comments

Comments
 (0)