diff --git a/CHANGELOG.md b/CHANGELOG.md index a796f5f..c16da36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@
+- [`b87254d`](https://github.com/stdlib-js/stdlib/commit/b87254d4535a3b90bf3d0068750ed6e9ca5dbc85) - **docs:** fix parameter descriptions in Weibull distribution packages _(by Philipp Burckhardt)_ - [`f9f468e`](https://github.com/stdlib-js/stdlib/commit/f9f468e240d7e5b5d155279e4386b8b606cd8227) - **feat:** add C implementation of `stats/base/dists/weibull/cdf` _(by Vinit Pandit, Philipp Burckhardt)_
diff --git a/README.md b/README.md index e7da764..be72582 100644 --- a/README.md +++ b/README.md @@ -222,8 +222,8 @@ double out = stdlib_base_dists_weibull_cdf( 2.0, 1.0, 1.0 ); The function accepts the following arguments: - **x**: `[in] double` input value. -- **k**: `[in] double` scale parameter. -- **lambda**: `[in] double` shape parameter. +- **k**: `[in] double` shape parameter. +- **lambda**: `[in] double` scale parameter. ```c double stdlib_base_dists_weibull_cdf( const double x, const double k, const double lambda ); diff --git a/dist/index.js.map b/dist/index.js.map index ade897c..c68680a 100644 --- a/dist/index.js.map +++ b/dist/index.js.map @@ -1,7 +1,7 @@ { "version": 3, "sources": ["../lib/main.js", "../lib/factory.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 isnan = require( '@stdlib/math-base-assert-is-nan' );\nvar expm1 = require( '@stdlib/math-base-special-expm1' );\nvar pow = require( '@stdlib/math-base-special-pow' );\n\n\n// MAIN //\n\n/**\n* Evaluates the cumulative distribution function (CDF) for a Weibull distribution with scale parameter `k` and shape parameter `lambda` at a value `x`.\n*\n* @param {number} x - input value\n* @param {PositiveNumber} k - scale parameter\n* @param {PositiveNumber} lambda - shape parameter\n* @returns {Probability} evaluated CDF\n*\n* @example\n* var y = cdf( 2.0, 1.0, 1.0 );\n* // returns ~0.865\n*\n* @example\n* var y = cdf( -1.0, 2.0, 2.0 );\n* // returns 0.0\n*\n* @example\n* var y = cdf( +Infinity, 4.0, 2.0 );\n* // returns 1.0\n*\n* @example\n* var y = cdf( -Infinity, 4.0, 2.0 );\n* // returns 0.0\n*\n* @example\n* var y = cdf( NaN, 0.0, 1.0 );\n* // returns NaN\n*\n* @example\n* var y = cdf( 0.0, NaN, 1.0 );\n* // returns NaN\n*\n* @example\n* var y = cdf( 0.0, 0.0, NaN );\n* // returns NaN\n*\n* @example\n* var y = cdf( 2.0, 0.0, -1.0 );\n* // returns NaN\n*/\nfunction cdf( x, k, lambda ) {\n\tif (\n\t\tisnan( x ) ||\n\t\tisnan( k ) ||\n\t\tisnan( lambda ) ||\n\t\tk <= 0.0 ||\n\t\tlambda <= 0.0\n\t) {\n\t\treturn NaN;\n\t}\n\tif ( x < 0.0 ) {\n\t\treturn 0.0;\n\t}\n\treturn -expm1( -pow( x / lambda, k ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = cdf;\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// MODULES //\n\nvar constantFunction = require( '@stdlib/utils-constant-function' );\nvar isnan = require( '@stdlib/math-base-assert-is-nan' );\nvar expm1 = require( '@stdlib/math-base-special-expm1' );\nvar pow = require( '@stdlib/math-base-special-pow' );\n\n\n// MAIN //\n\n/**\n* Returns a function for evaluating the cumulative distribution function (CDF) for a Weibull distribution.\n*\n* @param {PositiveNumber} k - scale parameter\n* @param {PositiveNumber} lambda - shape parameter\n* @returns {Function} CDF\n*\n* @example\n* var cdf = factory( 2.0, 10.0 );\n* var y = cdf( 12.0 );\n* // returns ~0.763\n*\n* y = cdf( 8.0 );\n* // returns ~0.473\n*/\nfunction factory( k, lambda ) {\n\tif (\n\t\tisnan( k ) ||\n\t\tisnan( lambda ) ||\n\t\tk <= 0.0 ||\n\t\tlambda <= 0.0\n\t) {\n\t\treturn constantFunction( NaN );\n\t}\n\treturn cdf;\n\n\t/**\n\t* Evaluates the cumulative distribution function (CDF) for a Weibull distribution.\n\t*\n\t* @private\n\t* @param {number} x - input value\n\t* @returns {Probability} evaluated CDF\n\t*\n\t* @example\n\t* var y = cdf( 2.0 );\n\t* // returns \n\t*/\n\tfunction cdf( x ) {\n\t\tif ( isnan( x ) ) {\n\t\t\treturn NaN;\n\t\t}\n\t\tif ( x < 0.0 ) {\n\t\t\treturn 0.0;\n\t\t}\n\t\treturn -expm1( -pow( x / lambda, k ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\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* Weibull distribution cumulative distribution function (CDF).\n*\n* @module @stdlib/stats-base-dists-weibull-cdf\n*\n* @example\n* var cdf = require( '@stdlib/stats-base-dists-weibull-cdf' );\n*\n* var y = cdf( 2.0, 1.0, 1.0 );\n* // returns ~0.865\n*\n* var myCDF = cdf.factory( 2.0, 10.0 );\n* y = myCDF( 12.0 );\n* // returns ~0.763\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar factory = require( './factory.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], + "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 isnan = require( '@stdlib/math-base-assert-is-nan' );\nvar expm1 = require( '@stdlib/math-base-special-expm1' );\nvar pow = require( '@stdlib/math-base-special-pow' );\n\n\n// MAIN //\n\n/**\n* Evaluates the cumulative distribution function (CDF) for a Weibull distribution with scale parameter `k` and shape parameter `lambda` at a value `x`.\n*\n* @param {number} x - input value\n* @param {PositiveNumber} k - shape parameter\n* @param {PositiveNumber} lambda - scale parameter\n* @returns {Probability} evaluated CDF\n*\n* @example\n* var y = cdf( 2.0, 1.0, 1.0 );\n* // returns ~0.865\n*\n* @example\n* var y = cdf( -1.0, 2.0, 2.0 );\n* // returns 0.0\n*\n* @example\n* var y = cdf( +Infinity, 4.0, 2.0 );\n* // returns 1.0\n*\n* @example\n* var y = cdf( -Infinity, 4.0, 2.0 );\n* // returns 0.0\n*\n* @example\n* var y = cdf( NaN, 0.0, 1.0 );\n* // returns NaN\n*\n* @example\n* var y = cdf( 0.0, NaN, 1.0 );\n* // returns NaN\n*\n* @example\n* var y = cdf( 0.0, 0.0, NaN );\n* // returns NaN\n*\n* @example\n* var y = cdf( 2.0, 0.0, -1.0 );\n* // returns NaN\n*/\nfunction cdf( x, k, lambda ) {\n\tif (\n\t\tisnan( x ) ||\n\t\tisnan( k ) ||\n\t\tisnan( lambda ) ||\n\t\tk <= 0.0 ||\n\t\tlambda <= 0.0\n\t) {\n\t\treturn NaN;\n\t}\n\tif ( x < 0.0 ) {\n\t\treturn 0.0;\n\t}\n\treturn -expm1( -pow( x / lambda, k ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = cdf;\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// MODULES //\n\nvar constantFunction = require( '@stdlib/utils-constant-function' );\nvar isnan = require( '@stdlib/math-base-assert-is-nan' );\nvar expm1 = require( '@stdlib/math-base-special-expm1' );\nvar pow = require( '@stdlib/math-base-special-pow' );\n\n\n// MAIN //\n\n/**\n* Returns a function for evaluating the cumulative distribution function (CDF) for a Weibull distribution.\n*\n* @param {PositiveNumber} k - shape parameter\n* @param {PositiveNumber} lambda - scale parameter\n* @returns {Function} CDF\n*\n* @example\n* var cdf = factory( 2.0, 10.0 );\n* var y = cdf( 12.0 );\n* // returns ~0.763\n*\n* y = cdf( 8.0 );\n* // returns ~0.473\n*/\nfunction factory( k, lambda ) {\n\tif (\n\t\tisnan( k ) ||\n\t\tisnan( lambda ) ||\n\t\tk <= 0.0 ||\n\t\tlambda <= 0.0\n\t) {\n\t\treturn constantFunction( NaN );\n\t}\n\treturn cdf;\n\n\t/**\n\t* Evaluates the cumulative distribution function (CDF) for a Weibull distribution.\n\t*\n\t* @private\n\t* @param {number} x - input value\n\t* @returns {Probability} evaluated CDF\n\t*\n\t* @example\n\t* var y = cdf( 2.0 );\n\t* // returns \n\t*/\n\tfunction cdf( x ) {\n\t\tif ( isnan( x ) ) {\n\t\t\treturn NaN;\n\t\t}\n\t\tif ( x < 0.0 ) {\n\t\t\treturn 0.0;\n\t\t}\n\t\treturn -expm1( -pow( x / lambda, k ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\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* Weibull distribution cumulative distribution function (CDF).\n*\n* @module @stdlib/stats-base-dists-weibull-cdf\n*\n* @example\n* var cdf = require( '@stdlib/stats-base-dists-weibull-cdf' );\n*\n* var y = cdf( 2.0, 1.0, 1.0 );\n* // returns ~0.865\n*\n* var myCDF = cdf.factory( 2.0, 10.0 );\n* y = myCDF( 12.0 );\n* // returns ~0.763\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar factory = require( './factory.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAQ,QAAS,iCAAkC,EACnDC,EAAQ,QAAS,iCAAkC,EACnDC,EAAM,QAAS,+BAAgC,EA6CnD,SAASC,EAAKC,EAAGC,EAAGC,EAAS,CAC5B,OACCN,EAAOI,CAAE,GACTJ,EAAOK,CAAE,GACTL,EAAOM,CAAO,GACdD,GAAK,GACLC,GAAU,EAEH,IAEHF,EAAI,EACD,EAED,CAACH,EAAO,CAACC,EAAKE,EAAIE,EAAQD,CAAE,CAAE,CACtC,CAKAN,EAAO,QAAUI,ICxFjB,IAAAI,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAmB,QAAS,iCAAkC,EAC9DC,EAAQ,QAAS,iCAAkC,EACnDC,EAAQ,QAAS,iCAAkC,EACnDC,EAAM,QAAS,+BAAgC,EAoBnD,SAASC,EAASC,EAAGC,EAAS,CAC7B,GACCL,EAAOI,CAAE,GACTJ,EAAOK,CAAO,GACdD,GAAK,GACLC,GAAU,EAEV,OAAON,EAAkB,GAAI,EAE9B,OAAOO,EAaP,SAASA,EAAKC,EAAI,CACjB,OAAKP,EAAOO,CAAE,EACN,IAEHA,EAAI,EACD,EAED,CAACN,EAAO,CAACC,EAAKK,EAAIF,EAAQD,CAAE,CAAE,CACtC,CACD,CAKAN,EAAO,QAAUK,IC3CjB,IAAIK,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAU,IAKdF,EAAaC,EAAM,UAAWC,CAAQ,EAKtC,OAAO,QAAUD", "names": ["require_main", "__commonJSMin", "exports", "module", "isnan", "expm1", "pow", "cdf", "x", "k", "lambda", "require_factory", "__commonJSMin", "exports", "module", "constantFunction", "isnan", "expm1", "pow", "factory", "k", "lambda", "cdf", "x", "setReadOnly", "main", "factory"] } diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts index a111bd4..564dc00 100644 --- a/docs/types/index.d.ts +++ b/docs/types/index.d.ts @@ -38,8 +38,8 @@ interface CDF { * - If provided a non-positive value for `lambda` or `k`, the function returns `NaN`. * * @param x - input value - * @param k - scale parameter - * @param lambda - shape parameter + * @param k - shape parameter + * @param lambda - scale parameter * @returns evaluated CDF * * @example @@ -79,8 +79,8 @@ interface CDF { /** * Returns a function for evaluating the cumulative distribution function (CDF) for a Weibull distribution. * - * @param k - scale parameter - * @param lambda - shape parameter + * @param k - shape parameter + * @param lambda - scale parameter * @returns CDF * * @example @@ -98,8 +98,8 @@ interface CDF { * Weibull distribution cumulative distribution function (CDF). * * @param x - input value -* @param k - scale parameter -* @param lambda - shape parameter +* @param k - shape parameter +* @param lambda - scale parameter * @returns evaluated CDF * * @example diff --git a/lib/factory.js b/lib/factory.js index 42ebb6a..156b48d 100644 --- a/lib/factory.js +++ b/lib/factory.js @@ -31,8 +31,8 @@ var pow = require( '@stdlib/math-base-special-pow' ); /** * Returns a function for evaluating the cumulative distribution function (CDF) for a Weibull distribution. * -* @param {PositiveNumber} k - scale parameter -* @param {PositiveNumber} lambda - shape parameter +* @param {PositiveNumber} k - shape parameter +* @param {PositiveNumber} lambda - scale parameter * @returns {Function} CDF * * @example diff --git a/lib/main.js b/lib/main.js index 93a96b1..ecdc4eb 100644 --- a/lib/main.js +++ b/lib/main.js @@ -31,8 +31,8 @@ var pow = require( '@stdlib/math-base-special-pow' ); * Evaluates the cumulative distribution function (CDF) for a Weibull distribution with scale parameter `k` and shape parameter `lambda` at a value `x`. * * @param {number} x - input value -* @param {PositiveNumber} k - scale parameter -* @param {PositiveNumber} lambda - shape parameter +* @param {PositiveNumber} k - shape parameter +* @param {PositiveNumber} lambda - scale parameter * @returns {Probability} evaluated CDF * * @example diff --git a/lib/native.js b/lib/native.js index d63f6f7..0f8cac5 100644 --- a/lib/native.js +++ b/lib/native.js @@ -30,8 +30,8 @@ var addon = require( './../src/addon.node' ); * * @private * @param {number} x - input value -* @param {PositiveNumber} k - scale parameter -* @param {PositiveNumber} lambda - shape parameter +* @param {PositiveNumber} k - shape parameter +* @param {PositiveNumber} lambda - scale parameter * @returns {Probability} evaluated CDF * * @example diff --git a/src/main.c b/src/main.c index be5f65b..c5ccc58 100644 --- a/src/main.c +++ b/src/main.c @@ -25,8 +25,8 @@ * Evaluates the cumulative distribution function (CDF) for a Weibull distribution with scale parameter `k` and shape parameter `lambda` at a value `x`. * * @param x input value -* @param k scale parameter -* @param lambda shape parameter +* @param k shape parameter +* @param lambda scale parameter * @return evaluated CDF * * @example