From 23003e60463565d10a47b38c4409bdd32fc4f73f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 16 Dec 2024 21:31:31 +0000 Subject: [PATCH] Auto-generated commit --- CHANGELOG.md | 4 +++- dist/index.js.map | 4 ++-- lib/main.js | 4 +--- src/main.c | 4 +--- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e938ba6..2fffd28 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ This release closes the following issue:
+- [`ccbaa42`](https://github.com/stdlib-js/stdlib/commit/ccbaa42486fd36b15e2c17b0d30e0b0508f533d6) - **style:** fix formatting _(by Athan Reines)_ - [`930ed98`](https://github.com/stdlib-js/stdlib/commit/930ed98207b9ae67f00b23917755589dbbd03fe5) - **feat:** add C implementation for `stats/base/dists/uniform/variance` [(#3951)](https://github.com/stdlib-js/stdlib/pull/3951) _(by Aayush Khanna)_
@@ -46,9 +47,10 @@ This release closes the following issue: ### Contributors -A total of 1 person contributed to this release. Thank you to this contributor: +A total of 2 people contributed to this release. Thank you to the following contributors: - Aayush Khanna +- Athan Reines diff --git a/dist/index.js.map b/dist/index.js.map index b341726..6c88efc 100644 --- a/dist/index.js.map +++ b/dist/index.js.map @@ -1,7 +1,7 @@ { "version": 3, "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar pow = require( '@stdlib/math-base-special-pow' );\n\n\n// MAIN //\n\n/**\n* Returns the variance of a uniform distribution.\n*\n* @param {number} a - minimum support\n* @param {number} b - maximum support\n* @returns {PositiveNumber} variance\n*\n* @example\n* var v = variance( 0.0, 1.0 );\n* // returns ~0.083\n*\n* @example\n* var v = variance( 4.0, 12.0 );\n* // returns ~5.333\n*\n* @example\n* var v = variance( -4.0, 4.0 );\n* // returns ~5.333\n*\n* @example\n* var v = variance( 1.0, -0.1 );\n* // returns NaN\n*\n* @example\n* var v = variance( 2.0, NaN );\n* // returns NaN\n*\n* @example\n* var v = variance( NaN, 2.0 );\n* // returns NaN\n*/\nfunction variance( a, b ) {\n\tif (\n\t\ta >= b\n\t) {\n\t\treturn NaN;\n\t}\n\treturn (1.0/12.0) * pow( b-a, 2.0 );\n}\n\n\n// EXPORTS //\n\nmodule.exports = variance;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Uniform distribution variance.\n*\n* @module @stdlib/stats-base-dists-uniform-variance\n*\n* @example\n* var variance = require( '@stdlib/stats-base-dists-uniform-variance' );\n*\n* var v = variance( 0.0, 1.0 );\n* // returns ~0.083\n*\n* v = variance( 4.0, 12.0 );\n* // returns ~5.333\n*\n* v = variance( 2.0, 8.0 );\n* // returns 3.0\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAM,QAAS,+BAAgC,EAoCnD,SAASC,EAAUC,EAAGC,EAAI,CACzB,OACCD,GAAKC,EAEE,IAEA,EAAI,GAAQH,EAAKG,EAAED,EAAG,CAAI,CACnC,CAKAH,EAAO,QAAUE,IC9BjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", + "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar pow = require( '@stdlib/math-base-special-pow' );\n\n\n// MAIN //\n\n/**\n* Returns the variance of a uniform distribution.\n*\n* @param {number} a - minimum support\n* @param {number} b - maximum support\n* @returns {PositiveNumber} variance\n*\n* @example\n* var v = variance( 0.0, 1.0 );\n* // returns ~0.083\n*\n* @example\n* var v = variance( 4.0, 12.0 );\n* // returns ~5.333\n*\n* @example\n* var v = variance( -4.0, 4.0 );\n* // returns ~5.333\n*\n* @example\n* var v = variance( 1.0, -0.1 );\n* // returns NaN\n*\n* @example\n* var v = variance( 2.0, NaN );\n* // returns NaN\n*\n* @example\n* var v = variance( NaN, 2.0 );\n* // returns NaN\n*/\nfunction variance( a, b ) {\n\tif ( a >= b ) {\n\t\treturn NaN;\n\t}\n\treturn (1.0/12.0) * pow( b-a, 2.0 );\n}\n\n\n// EXPORTS //\n\nmodule.exports = variance;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Uniform distribution variance.\n*\n* @module @stdlib/stats-base-dists-uniform-variance\n*\n* @example\n* var variance = require( '@stdlib/stats-base-dists-uniform-variance' );\n*\n* var v = variance( 0.0, 1.0 );\n* // returns ~0.083\n*\n* v = variance( 4.0, 12.0 );\n* // returns ~5.333\n*\n* v = variance( 2.0, 8.0 );\n* // returns 3.0\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], + "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAM,QAAS,+BAAgC,EAoCnD,SAASC,EAAUC,EAAGC,EAAI,CACzB,OAAKD,GAAKC,EACF,IAEA,EAAI,GAAQH,EAAKG,EAAED,EAAG,CAAI,CACnC,CAKAH,EAAO,QAAUE,IC5BjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", "names": ["require_main", "__commonJSMin", "exports", "module", "pow", "variance", "a", "b", "main"] } diff --git a/lib/main.js b/lib/main.js index 6869f05..8d60842 100644 --- a/lib/main.js +++ b/lib/main.js @@ -57,9 +57,7 @@ var pow = require( '@stdlib/math-base-special-pow' ); * // returns NaN */ function variance( a, b ) { - if ( - a >= b - ) { + if ( a >= b ) { return NaN; } return (1.0/12.0) * pow( b-a, 2.0 ); diff --git a/src/main.c b/src/main.c index 272abe4..b756d3e 100644 --- a/src/main.c +++ b/src/main.c @@ -31,9 +31,7 @@ * // returns ~0.083 */ double stdlib_base_dists_uniform_variance( const double a, const double b ) { - if ( - a >= b - ) { + if ( a >= b ) { return 0.0 / 0.0; // NaN } return ( 1.0 / 12.0 ) * stdlib_base_pow( b - a, 2.0 );