@stdlib/stats-base-dists-erlang-logpdf 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE +1 -1
- package/README.md +16 -20
- package/dist/index.d.ts +2 -2
- package/dist/index.js.map +1 -1
- package/docs/types/index.d.ts +3 -3
- package/lib/index.js +1 -1
- package/package.json +5 -5
package/NOTICE
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Copyright (c) 2016-
|
|
1
|
+
Copyright (c) 2016-2026 The Stdlib Authors.
|
package/README.md
CHANGED
|
@@ -155,23 +155,19 @@ y = mylogpdf( 4.0 );
|
|
|
155
155
|
<!-- eslint no-undef: "error" -->
|
|
156
156
|
|
|
157
157
|
```javascript
|
|
158
|
-
var
|
|
159
|
-
var
|
|
158
|
+
var uniform = require( '@stdlib/random-array-uniform' );
|
|
159
|
+
var discreteUniform = require( '@stdlib/random-array-discrete-uniform' );
|
|
160
|
+
var logEachMap = require( '@stdlib/console-log-each-map' );
|
|
160
161
|
var logpdf = require( '@stdlib/stats-base-dists-erlang-logpdf' );
|
|
161
162
|
|
|
162
|
-
var
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
var
|
|
166
|
-
var
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
k = round( randu() * 10.0 );
|
|
171
|
-
lambda = randu() * 5.0;
|
|
172
|
-
y = logpdf( x, k, lambda );
|
|
173
|
-
console.log( 'x: %d, k: %d, λ: %d, ln(f(x;k,λ)): %d', x.toFixed( 4 ), k, lambda.toFixed( 4 ), y.toFixed( 4 ) );
|
|
174
|
-
}
|
|
163
|
+
var opts = {
|
|
164
|
+
'dtype': 'float64'
|
|
165
|
+
};
|
|
166
|
+
var x = uniform( 20, 0.0, 10.0, opts );
|
|
167
|
+
var k = discreteUniform( 20, 0, 10, opts );
|
|
168
|
+
var lambda = uniform( 20, 0.0, 5.0, opts );
|
|
169
|
+
|
|
170
|
+
logEachMap( 'x: %0.4f, k: %d, λ: %0.4f, ln(f(x;k,λ)): %0.4f', x, k, lambda, logpdf );
|
|
175
171
|
```
|
|
176
172
|
|
|
177
173
|
</section>
|
|
@@ -212,7 +208,7 @@ See [LICENSE][stdlib-license].
|
|
|
212
208
|
|
|
213
209
|
## Copyright
|
|
214
210
|
|
|
215
|
-
Copyright © 2016-
|
|
211
|
+
Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors].
|
|
216
212
|
|
|
217
213
|
</section>
|
|
218
214
|
|
|
@@ -225,8 +221,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
225
221
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/stats-base-dists-erlang-logpdf.svg
|
|
226
222
|
[npm-url]: https://npmjs.org/package/@stdlib/stats-base-dists-erlang-logpdf
|
|
227
223
|
|
|
228
|
-
[test-image]: https://github.com/stdlib-js/stats-base-dists-erlang-logpdf/actions/workflows/test.yml/badge.svg?branch=v0.2.
|
|
229
|
-
[test-url]: https://github.com/stdlib-js/stats-base-dists-erlang-logpdf/actions/workflows/test.yml?query=branch:v0.2.
|
|
224
|
+
[test-image]: https://github.com/stdlib-js/stats-base-dists-erlang-logpdf/actions/workflows/test.yml/badge.svg?branch=v0.2.3
|
|
225
|
+
[test-url]: https://github.com/stdlib-js/stats-base-dists-erlang-logpdf/actions/workflows/test.yml?query=branch:v0.2.3
|
|
230
226
|
|
|
231
227
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/stats-base-dists-erlang-logpdf/main.svg
|
|
232
228
|
[coverage-url]: https://codecov.io/github/stdlib-js/stats-base-dists-erlang-logpdf?branch=main
|
|
@@ -238,8 +234,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
238
234
|
|
|
239
235
|
-->
|
|
240
236
|
|
|
241
|
-
[chat-image]: https://img.shields.io/
|
|
242
|
-
[chat-url]: https://
|
|
237
|
+
[chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
|
|
238
|
+
[chat-url]: https://stdlib.zulipchat.com
|
|
243
239
|
|
|
244
240
|
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
245
241
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference path="../docs/types/index.d.ts" />
|
|
2
|
-
import
|
|
3
|
-
export =
|
|
2
|
+
import logpdf from '../docs/types/index';
|
|
3
|
+
export = logpdf;
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../lib/main.js", "../lib/factory.js", "../lib/index.js"],
|
|
4
|
-
"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 isNonNegativeInteger = require( '@stdlib/math-base-assert-is-nonnegative-integer' );\nvar gammaLogPDF = require( '@stdlib/stats-base-dists-gamma-logpdf' );\n\n\n// MAIN //\n\n/**\n* Evaluates the natural logarithm of the probability density function (PDF) for an Erlang distribution with shape parameter `k` and rate parameter `lambda` at a value `x`.\n*\n* @param {number} x - input value\n* @param {NonNegativeInteger} k - shape parameter\n* @param {PositiveNumber} lambda - rate parameter\n* @returns {number} evaluated logPDF\n*\n* @example\n* var y = logpdf( 0.1, 1, 1.0 );\n* // returns ~-0.1\n*\n* @example\n* var y = logpdf( 0.5, 2, 2.5 );\n* // returns ~-0.111\n*\n* @example\n* var y = logpdf( -1.0, 4, 2.0 );\n* // returns -Infinity\n*\n* @example\n* var y = logpdf( NaN, 1, 1.0 );\n* // returns NaN\n*\n* @example\n* var y = logpdf( 0.0, NaN, 1.0 );\n* // returns NaN\n*\n* @example\n* var y = logpdf( 0.0, 1, NaN );\n* // returns NaN\n*\n* @example\n* var y = logpdf( 2.0, -2, 0.5 );\n* // returns NaN\n*\n* @example\n* var y = logpdf( 2.0, 0.5, 0.5 );\n* // returns NaN\n*\n* @example\n* var y = logpdf( 2.0, 0.0, 2.0 );\n* // returns -Infinity\n*\n* @example\n* var y = logpdf( 0.0, 0.0, 2.0 );\n* // returns Infinity\n*\n* @example\n* var y = logpdf( 2.0, 1, 0.0 );\n* // returns NaN\n*\n* @example\n* var y = logpdf( 2.0, 1, -1.0 );\n* // returns NaN\n*/\nfunction logpdf( x, k, lambda ) {\n\tif ( !isNonNegativeInteger( k ) ) {\n\t\treturn NaN;\n\t}\n\treturn gammaLogPDF( x, k, lambda );\n}\n\n\n// EXPORTS //\n\nmodule.exports = logpdf;\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 isNonNegativeInteger = require( '@stdlib/math-base-assert-is-nonnegative-integer' );\nvar constantFunction = require( '@stdlib/utils-constant-function' );\nvar factoryGamma = require( '@stdlib/stats-base-dists-gamma-logpdf' ).factory;\n\n\n// MAIN //\n\n/**\n* Returns a function for evaluating the natural logarithm of the probability density function (PDF) for an Erlang distribution with shape parameter `k` and rate parameter `lambda`.\n*\n* @param {NonNegativeInteger} k - shape parameter\n* @param {PositiveNumber} lambda - rate parameter\n* @returns {Function} logPDF\n*\n* @example\n* var myLogPDF = factory( 6.0, 7.0 );\n* var y = myLogPDF( 7.0 );\n* // returns ~-32.382\n*/\nfunction factory( k, lambda ) {\n\tif ( !isNonNegativeInteger( k ) ) {\n\t\treturn constantFunction( NaN );\n\t}\n\treturn factoryGamma( k, lambda );\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* Natural logarithm of the probability density function (PDF) for an Erlang distribution.\n*\n* @module @stdlib/stats-base-dists-erlang-logpdf\n*\n* @example\n* var logpdf = require( '@stdlib/stats-base-dists-erlang-logpdf' );\n*\n* var y = logpdf( 0.5, 2, 2.5 );\n* // returns ~-0.111\n*\n* var myLogPDF = logpdf.factory( 6, 7.0 );\n* y = myLogPDF( 7.0 );\n* // returns ~-
|
|
4
|
+
"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 isNonNegativeInteger = require( '@stdlib/math-base-assert-is-nonnegative-integer' );\nvar gammaLogPDF = require( '@stdlib/stats-base-dists-gamma-logpdf' );\n\n\n// MAIN //\n\n/**\n* Evaluates the natural logarithm of the probability density function (PDF) for an Erlang distribution with shape parameter `k` and rate parameter `lambda` at a value `x`.\n*\n* @param {number} x - input value\n* @param {NonNegativeInteger} k - shape parameter\n* @param {PositiveNumber} lambda - rate parameter\n* @returns {number} evaluated logPDF\n*\n* @example\n* var y = logpdf( 0.1, 1, 1.0 );\n* // returns ~-0.1\n*\n* @example\n* var y = logpdf( 0.5, 2, 2.5 );\n* // returns ~-0.111\n*\n* @example\n* var y = logpdf( -1.0, 4, 2.0 );\n* // returns -Infinity\n*\n* @example\n* var y = logpdf( NaN, 1, 1.0 );\n* // returns NaN\n*\n* @example\n* var y = logpdf( 0.0, NaN, 1.0 );\n* // returns NaN\n*\n* @example\n* var y = logpdf( 0.0, 1, NaN );\n* // returns NaN\n*\n* @example\n* var y = logpdf( 2.0, -2, 0.5 );\n* // returns NaN\n*\n* @example\n* var y = logpdf( 2.0, 0.5, 0.5 );\n* // returns NaN\n*\n* @example\n* var y = logpdf( 2.0, 0.0, 2.0 );\n* // returns -Infinity\n*\n* @example\n* var y = logpdf( 0.0, 0.0, 2.0 );\n* // returns Infinity\n*\n* @example\n* var y = logpdf( 2.0, 1, 0.0 );\n* // returns NaN\n*\n* @example\n* var y = logpdf( 2.0, 1, -1.0 );\n* // returns NaN\n*/\nfunction logpdf( x, k, lambda ) {\n\tif ( !isNonNegativeInteger( k ) ) {\n\t\treturn NaN;\n\t}\n\treturn gammaLogPDF( x, k, lambda );\n}\n\n\n// EXPORTS //\n\nmodule.exports = logpdf;\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 isNonNegativeInteger = require( '@stdlib/math-base-assert-is-nonnegative-integer' );\nvar constantFunction = require( '@stdlib/utils-constant-function' );\nvar factoryGamma = require( '@stdlib/stats-base-dists-gamma-logpdf' ).factory;\n\n\n// MAIN //\n\n/**\n* Returns a function for evaluating the natural logarithm of the probability density function (PDF) for an Erlang distribution with shape parameter `k` and rate parameter `lambda`.\n*\n* @param {NonNegativeInteger} k - shape parameter\n* @param {PositiveNumber} lambda - rate parameter\n* @returns {Function} logPDF\n*\n* @example\n* var myLogPDF = factory( 6.0, 7.0 );\n* var y = myLogPDF( 7.0 );\n* // returns ~-32.382\n*/\nfunction factory( k, lambda ) {\n\tif ( !isNonNegativeInteger( k ) ) {\n\t\treturn constantFunction( NaN );\n\t}\n\treturn factoryGamma( k, lambda );\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* Natural logarithm of the probability density function (PDF) for an Erlang distribution.\n*\n* @module @stdlib/stats-base-dists-erlang-logpdf\n*\n* @example\n* var logpdf = require( '@stdlib/stats-base-dists-erlang-logpdf' );\n*\n* var y = logpdf( 0.5, 2, 2.5 );\n* // returns ~-0.111\n*\n* var myLogPDF = logpdf.factory( 6, 7.0 );\n* y = myLogPDF( 7.0 );\n* // returns ~-32.382\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"],
|
|
5
5
|
"mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAuB,QAAS,iDAAkD,EAClFC,EAAc,QAAS,uCAAwC,EA6DnE,SAASC,EAAQC,EAAGC,EAAGC,EAAS,CAC/B,OAAML,EAAsBI,CAAE,EAGvBH,EAAaE,EAAGC,EAAGC,CAAO,EAFzB,GAGT,CAKAN,EAAO,QAAUG,IC9FjB,IAAAI,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAuB,QAAS,iDAAkD,EAClFC,EAAmB,QAAS,iCAAkC,EAC9DC,EAAe,QAAS,uCAAwC,EAAE,QAiBtE,SAASC,EAASC,EAAGC,EAAS,CAC7B,OAAML,EAAsBI,CAAE,EAGvBF,EAAcE,EAAGC,CAAO,EAFvBJ,EAAkB,GAAI,CAG/B,CAKAF,EAAO,QAAUI,ICbjB,IAAIG,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAU,IAKdF,EAAaC,EAAM,UAAWC,CAAQ,EAKtC,OAAO,QAAUD",
|
|
6
6
|
"names": ["require_main", "__commonJSMin", "exports", "module", "isNonNegativeInteger", "gammaLogPDF", "logpdf", "x", "k", "lambda", "require_factory", "__commonJSMin", "exports", "module", "isNonNegativeInteger", "constantFunction", "factoryGamma", "factory", "k", "lambda", "setReadOnly", "main", "factory"]
|
|
7
7
|
}
|
package/docs/types/index.d.ts
CHANGED
|
@@ -122,11 +122,11 @@ interface LogPDF {
|
|
|
122
122
|
*
|
|
123
123
|
* var myLogPDF = logpdf.factory( 6, 7.0 );
|
|
124
124
|
* y = myLogPDF( 7.0 );
|
|
125
|
-
* // returns ~-
|
|
125
|
+
* // returns ~-32.382
|
|
126
126
|
*/
|
|
127
|
-
declare var
|
|
127
|
+
declare var logpdf: LogPDF;
|
|
128
128
|
|
|
129
129
|
|
|
130
130
|
// EXPORTS //
|
|
131
131
|
|
|
132
|
-
export =
|
|
132
|
+
export = logpdf;
|
package/lib/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stdlib/stats-base-dists-erlang-logpdf",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Natural logarithm of the probability density function (PDF) for an Erlang distribution.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
"url": "https://github.com/stdlib-js/stdlib/issues"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@stdlib/math-base-assert-is-nonnegative-integer": "^0.
|
|
34
|
-
"@stdlib/stats-base-dists-gamma-logpdf": "^0.
|
|
35
|
-
"@stdlib/utils-constant-function": "^0.2.
|
|
36
|
-
"@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.
|
|
33
|
+
"@stdlib/math-base-assert-is-nonnegative-integer": "^0.2.2",
|
|
34
|
+
"@stdlib/stats-base-dists-gamma-logpdf": "^0.3.0",
|
|
35
|
+
"@stdlib/utils-constant-function": "^0.2.3",
|
|
36
|
+
"@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {},
|
|
39
39
|
"engines": {
|