@stdlib/stats-base-dists-gamma-logpdf 0.0.7 → 0.2.0
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 +18 -4
- package/SECURITY.md +5 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +7 -0
- package/docs/types/index.d.ts +1 -1
- package/lib/index.js +3 -3
- package/package.json +30 -29
- package/docs/repl.txt +0 -83
- package/docs/types/test.ts +0 -119
- /package/lib/{logpdf.js → main.js} +0 -0
package/NOTICE
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Copyright (c) 2016-
|
|
1
|
+
Copyright (c) 2016-2024 The Stdlib Authors.
|
package/README.md
CHANGED
|
@@ -18,6 +18,17 @@ limitations under the License.
|
|
|
18
18
|
|
|
19
19
|
-->
|
|
20
20
|
|
|
21
|
+
|
|
22
|
+
<details>
|
|
23
|
+
<summary>
|
|
24
|
+
About stdlib...
|
|
25
|
+
</summary>
|
|
26
|
+
<p>We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.</p>
|
|
27
|
+
<p>The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.</p>
|
|
28
|
+
<p>When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.</p>
|
|
29
|
+
<p>To join us in bringing numerical computing to the web, get started by checking us out on <a href="https://github.com/stdlib-js/stdlib">GitHub</a>, and please consider <a href="https://opencollective.com/stdlib">financially supporting stdlib</a>. We greatly appreciate your continued support!</p>
|
|
30
|
+
</details>
|
|
31
|
+
|
|
21
32
|
# Logarithm of Probability Density Function
|
|
22
33
|
|
|
23
34
|
[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] <!-- [![dependencies][dependencies-image]][dependencies-url] -->
|
|
@@ -197,7 +208,7 @@ See [LICENSE][stdlib-license].
|
|
|
197
208
|
|
|
198
209
|
## Copyright
|
|
199
210
|
|
|
200
|
-
Copyright © 2016-
|
|
211
|
+
Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
201
212
|
|
|
202
213
|
</section>
|
|
203
214
|
|
|
@@ -210,8 +221,8 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors].
|
|
|
210
221
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/stats-base-dists-gamma-logpdf.svg
|
|
211
222
|
[npm-url]: https://npmjs.org/package/@stdlib/stats-base-dists-gamma-logpdf
|
|
212
223
|
|
|
213
|
-
[test-image]: https://github.com/stdlib-js/stats-base-dists-gamma-logpdf/actions/workflows/test.yml/badge.svg?branch=v0.0
|
|
214
|
-
[test-url]: https://github.com/stdlib-js/stats-base-dists-gamma-logpdf/actions/workflows/test.yml?query=branch:v0.0
|
|
224
|
+
[test-image]: https://github.com/stdlib-js/stats-base-dists-gamma-logpdf/actions/workflows/test.yml/badge.svg?branch=v0.2.0
|
|
225
|
+
[test-url]: https://github.com/stdlib-js/stats-base-dists-gamma-logpdf/actions/workflows/test.yml?query=branch:v0.2.0
|
|
215
226
|
|
|
216
227
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/stats-base-dists-gamma-logpdf/main.svg
|
|
217
228
|
[coverage-url]: https://codecov.io/github/stdlib-js/stats-base-dists-gamma-logpdf?branch=main
|
|
@@ -224,7 +235,7 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors].
|
|
|
224
235
|
-->
|
|
225
236
|
|
|
226
237
|
[chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
|
|
227
|
-
[chat-url]: https://gitter.im
|
|
238
|
+
[chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
|
|
228
239
|
|
|
229
240
|
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
230
241
|
|
|
@@ -234,8 +245,11 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors].
|
|
|
234
245
|
[es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
|
|
235
246
|
|
|
236
247
|
[deno-url]: https://github.com/stdlib-js/stats-base-dists-gamma-logpdf/tree/deno
|
|
248
|
+
[deno-readme]: https://github.com/stdlib-js/stats-base-dists-gamma-logpdf/blob/deno/README.md
|
|
237
249
|
[umd-url]: https://github.com/stdlib-js/stats-base-dists-gamma-logpdf/tree/umd
|
|
250
|
+
[umd-readme]: https://github.com/stdlib-js/stats-base-dists-gamma-logpdf/blob/umd/README.md
|
|
238
251
|
[esm-url]: https://github.com/stdlib-js/stats-base-dists-gamma-logpdf/tree/esm
|
|
252
|
+
[esm-readme]: https://github.com/stdlib-js/stats-base-dists-gamma-logpdf/blob/esm/README.md
|
|
239
253
|
[branches-url]: https://github.com/stdlib-js/stats-base-dists-gamma-logpdf/blob/main/branches.md
|
|
240
254
|
|
|
241
255
|
[stdlib-license]: https://raw.githubusercontent.com/stdlib-js/stats-base-dists-gamma-logpdf/main/LICENSE
|
package/SECURITY.md
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";var o=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var y=o(function(vr,P){
|
|
2
|
+
var T=require('@stdlib/math-base-special-gamma-lanczos-sum-expg-scaled/dist'),j=require('@stdlib/math-base-special-gammaln/dist'),k=require('@stdlib/math-base-special-gamma/dist'),B=require('@stdlib/math-base-special-log1p/dist'),C=require('@stdlib/math-base-special-sqrt/dist'),H=require('@stdlib/math-base-special-abs/dist'),t=require('@stdlib/math-base-special-exp/dist'),s=require('@stdlib/math-base-special-pow/dist'),c=require('@stdlib/math-base-special-max/dist'),l=require('@stdlib/math-base-special-min/dist'),I=require('@stdlib/math-base-special-ln/dist'),N=require('@stdlib/constants-float64-max-ln/dist'),m=require('@stdlib/constants-float64-min-ln/dist'),g=require('@stdlib/constants-float64-gamma-lanczos-g/dist'),J=require('@stdlib/constants-float64-e/dist');function K(r,e){var i,n,v,a,u,q,f;return v=r+g-.5,f=(e-r-g+.5)/v,r<1?e<=m?t(r*I(e)-e-j(r)):s(e,r)*t(-e)/k(r):(H(f*f*r)<=100&&r>150?(i=r*(B(f)-f)+e*(.5-g)/v,i=t(i)):(a=r*I(e/v),u=r-e,l(a,u)<=m||c(a,u)>=N?(n=u/r,l(a,u)/2>m&&c(a,u)/2<N?(q=s(e/v,r/2)*t(u/2),i=q*q):l(a,u)/4>m&&c(a,u)/4<N&&e>r?(q=s(e/v,r/4)*t(u/4),i=q*q,i*=i):n>m&&n<N?i=s(e*t(n)/v,r):i=t(a+u)):i=s(e/v,r)*t(u)),i*=C(v/J)/T(r),i)}P.exports=K
|
|
3
|
+
});var d=o(function(ar,D){
|
|
4
|
+
var Q=require('@stdlib/math-base-special-gammaln/dist'),U=require('@stdlib/math-base-special-exp/dist'),G=require('@stdlib/math-base-special-ln/dist'),A=require('@stdlib/constants-float64-pinf/dist'),V=require('@stdlib/constants-float64-max/dist'),W=y();function Y(r,e){var i;return r<=0?NaN:e<0?NaN:e===0?r>1?0:r===1?1:A:(i=W(r,e),e<1&&V*e<i?A:(i===0?(i=r*G(e)-e-Q(r)-G(e),i=U(i)):i/=e,i))}D.exports=Y
|
|
5
|
+
});var O=o(function(tr,E){
|
|
6
|
+
var p=require('@stdlib/math-base-assert-is-nan/dist'),L=require('@stdlib/math-base-special-ln/dist'),M=require('@stdlib/constants-float64-pinf/dist'),_=require('@stdlib/constants-float64-ninf/dist'),Z=d();function $(r,e,i){return p(r)||p(e)||p(i)||e<0||i<=0?NaN:r<0||r===M?_:e===0?r===0?M:_:L(Z(e,r*i))+L(i)}E.exports=$
|
|
7
|
+
});var w=o(function(qr,X){
|
|
8
|
+
var x=require('@stdlib/utils-constant-function/dist'),b=require('@stdlib/stats-base-dists-degenerate-logpdf/dist').factory,F=require('@stdlib/math-base-assert-is-nan/dist'),S=require('@stdlib/math-base-special-ln/dist'),h=require('@stdlib/constants-float64-ninf/dist'),z=require('@stdlib/constants-float64-pinf/dist'),rr=d();function er(r,e){if(F(r)||F(e)||r<0||e<=0)return x(NaN);if(r===0)return b(0);return i;function i(n){return F(n)?NaN:n<0||n===z?h:S(rr(r,n*e))+S(e)}}X.exports=er
|
|
9
|
+
});var ir=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),R=O(),ur=w();ir(R,"factory",ur);module.exports=R;
|
|
10
|
+
/** @license Apache-2.0 */
|
|
11
|
+
/** @license Apache-2.0 */
|
|
12
|
+
/** @license Apache-2.0 */
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../lib/regularised_gamma_prefix.js", "../lib/gamma_p_derivative.js", "../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* ## Notice\n*\n* The original C++ code and copyright notice are from the [Boost library]{@link http://www.boost.org/doc/libs/1_64_0/boost/math/special_functions/gamma.hpp}. The implementation has been modified for JavaScript.\n*\n* ```text\n* Copyright John Maddock 2006-7, 2013-14.\n* Copyright Paul A. Bristow 2007, 2013-14.\n* Copyright Nikhar Agrawal 2013-14.\n* Copyright Christopher Kormanyos 2013-14.\n*\n* Use, modification and distribution are subject to the\n* Boost Software License, Version 1.0. (See accompanying file\n* LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt)\n* ```\n*/\n\n'use strict';\n\n// MODULES //\n\nvar lanczosSumExpGScaled = require( '@stdlib/math-base-special-gamma-lanczos-sum-expg-scaled' );\nvar gammaln = require( '@stdlib/math-base-special-gammaln' );\nvar gamma = require( '@stdlib/math-base-special-gamma' );\nvar log1p = require( '@stdlib/math-base-special-log1p' );\nvar sqrt = require( '@stdlib/math-base-special-sqrt' );\nvar abs = require( '@stdlib/math-base-special-abs' );\nvar exp = require( '@stdlib/math-base-special-exp' );\nvar pow = require( '@stdlib/math-base-special-pow' );\nvar max = require( '@stdlib/math-base-special-max' );\nvar min = require( '@stdlib/math-base-special-min' );\nvar ln = require( '@stdlib/math-base-special-ln' );\nvar MAX_LN = require( '@stdlib/constants-float64-max-ln' );\nvar MIN_LN = require( '@stdlib/constants-float64-min-ln' );\nvar G = require( '@stdlib/constants-float64-gamma-lanczos-g' );\nvar E = require( '@stdlib/constants-float64-e' );\n\n\n// MAIN //\n\n/**\n* Computes `(z^a)*(e^-z) / gamma(a)`.\n*\n* @private\n* @param {number} a - input value\n* @param {number} z - input value\n* @returns {number} function value\n*/\nfunction regularisedGammaPrefix( a, z ) {\n\tvar prefix;\n\tvar amza;\n\tvar agh;\n\tvar alz;\n\tvar amz;\n\tvar sq;\n\tvar d;\n\n\tagh = a + G - 0.5;\n\td = ( (z - a) - G + 0.5 ) / agh;\n\tif ( a < 1.0 ) {\n\t\t// Treat a < 1 as a special case because our Lanczos approximations are optimized against the factorials with a > 1, and for high precision types very small values of `a` can give rather erroneous results for gamma:\n\t\tif ( z <= MIN_LN ) {\n\t\t\t// Use logs, so should be free of cancellation errors:\n\t\t\treturn exp( ( a * ln(z) ) - z - gammaln( a ) );\n\t\t}\n\t\t// No danger of overflow as gamma(a) < 1/a for small a, so direct calculation:\n\t\treturn pow( z, a ) * exp( -z ) / gamma( a );\n\t}\n\tif ( abs(d*d*a) <= 100.0 && a > 150.0 ) {\n\t\t// Special case for large a and a ~ z:\n\t\tprefix = ( a * ( log1p( d ) - d ) ) + ( z * ( 0.5-G ) / agh );\n\t\tprefix = exp( prefix );\n\t}\n\telse {\n\t\t// General case. Direct computation is most accurate, but use various fallbacks for different parts of the problem domain:\n\t\talz = a * ln(z / agh);\n\t\tamz = a - z;\n\t\tif (\n\t\t\tmin(alz, amz) <= MIN_LN ||\n\t\t\tmax(alz, amz) >= MAX_LN\n\t\t) {\n\t\t\tamza = amz / a;\n\t\t\tif (\n\t\t\t\tmin(alz, amz)/2.0 > MIN_LN &&\n\t\t\t\tmax(alz, amz)/2.0 < MAX_LN\n\t\t\t) {\n\t\t\t\t// Compute square root of the result and then square it:\n\t\t\t\tsq = pow( z / agh, a / 2.0 ) * exp( amz / 2.0 );\n\t\t\t\tprefix = sq * sq;\n\t\t\t}\n\t\t\telse if (\n\t\t\t\tmin(alz, amz)/4.0 > MIN_LN &&\n\t\t\t\tmax(alz, amz)/4.0 < MAX_LN &&\n\t\t\t\tz > a\n\t\t\t) {\n\t\t\t\t// Compute the 4th root of the result then square it twice:\n\t\t\t\tsq = pow( z / agh, a / 4.0 ) * exp( amz / 4.0 );\n\t\t\t\tprefix = sq * sq;\n\t\t\t\tprefix *= prefix;\n\t\t\t}\n\t\t\telse if (\n\t\t\t\tamza > MIN_LN &&\n\t\t\t\tamza < MAX_LN\n\t\t\t) {\n\t\t\t\tprefix = pow( (z * exp(amza)) / agh, a );\n\t\t\t}\n\t\t\telse {\n\t\t\t\tprefix = exp( alz + amz );\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tprefix = pow( z / agh, a ) * exp( amz );\n\t\t}\n\t}\n\tprefix *= sqrt( agh / E ) / lanczosSumExpGScaled( a );\n\treturn prefix;\n}\n\n\n// EXPORTS //\n\nmodule.exports = regularisedGammaPrefix;\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* ## Notice\n*\n* The original C++ code and copyright notice are from the [Boost library]{@link http://www.boost.org/doc/libs/1_58_0/boost/math/special_functions/gamma.hpp}. The implementation has been modified for JavaScript.\n*\n* ```text\n* Copyright John Maddock 2006-7, 2013-14.\n* Copyright Paul A. Bristow 2007, 2013-14.\n* Copyright Nikhar Agrawal 2013-14.\n* Copyright Christopher Kormanyos 2013-14.\n*\n* Use, modification and distribution are subject to the\n* Boost Software License, Version 1.0. (See accompanying file\n* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)\n* ```\n*/\n\n'use strict';\n\n// MODULES //\n\nvar gammaln = require( '@stdlib/math-base-special-gammaln' );\nvar exp = require( '@stdlib/math-base-special-exp' );\nvar ln = require( '@stdlib/math-base-special-ln' );\nvar PINF = require( '@stdlib/constants-float64-pinf' );\nvar FLOAT64_MAX = require( '@stdlib/constants-float64-max' );\nvar regularisedGammaPrefix = require( './regularised_gamma_prefix.js' );\n\n\n// MAIN //\n\n/**\n* Calculates the partial derivative with respect to x of the incomplete gamma function.\n*\n* @private\n* @param {PositiveNumber} a - function parameter\n* @param {NonNegativeNumber} x - function parameter\n* @returns {number} function value\n*/\nfunction gammaPDerivative( a, x ) {\n\tvar f1;\n\tif ( a <= 0.0 ) {\n\t\treturn NaN;\n\t}\n\tif ( x < 0.0 ) {\n\t\treturn NaN;\n\t}\n\tif ( x === 0.0 ) {\n\t\tif ( a > 1.0 ) {\n\t\t\treturn 0.0;\n\t\t}\n\t\treturn ( a === 1.0 ) ? 1.0 : PINF;\n\t}\n\tf1 = regularisedGammaPrefix( a, x );\n\tif ( x < 1.0 && ( FLOAT64_MAX * x < f1 ) ) {\n\t\treturn PINF;\n\t}\n\tif ( f1 === 0.0 ) {\n\t\t// Underflow in calculation, use logs instead:\n\t\tf1 = (a * ln( x )) - x - gammaln( a ) - ln( x );\n\t\tf1 = exp( f1 );\n\t} else {\n\t\tf1 /= x;\n\t}\n\treturn f1;\n}\n\n\n// EXPORTS //\n\nmodule.exports = gammaPDerivative;\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 isnan = require( '@stdlib/math-base-assert-is-nan' );\nvar ln = require( '@stdlib/math-base-special-ln' );\nvar PINF = require( '@stdlib/constants-float64-pinf' );\nvar NINF = require( '@stdlib/constants-float64-ninf' );\nvar gammaDeriv = require( './gamma_p_derivative.js' );\n\n\n// MAIN //\n\n/**\n* Evaluates the logarithm of the probability density function (PDF) for a gamma distribution with shape parameter `alpha` and rate parameter `beta` at a value `x`.\n*\n* @param {number} x - input value\n* @param {NonNegativeNumber} alpha - shape parameter\n* @param {PositiveNumber} beta - rate parameter\n* @returns {number} evaluated logPDF\n*\n* @example\n* var y = logpdf( 2.0, 0.5, 1.0 );\n* // returns ~-2.919\n*\n* @example\n* var y = logpdf( 0.1, 1.0, 1.0 );\n* // returns ~-0.1\n*\n* @example\n* var y = logpdf( -1.0, 4.0, 2.0 );\n* // returns -Infinity\n*\n* @example\n* var y = logpdf( NaN, 0.6, 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.0, NaN );\n* // returns NaN\n*\n* @example\n* // Negative shape parameter:\n* var y = logpdf( 2.0, -1.0, 1.0 );\n* // returns NaN\n*\n* @example\n* // Negative rate parameter:\n* var y = logpdf( 2.0, 1.0, -1.0 );\n* // returns NaN\n*/\nfunction logpdf( x, alpha, beta ) {\n\tif (\n\t\tisnan( x ) ||\n\t\tisnan( alpha ) ||\n\t\tisnan( beta ) ||\n\t\talpha < 0.0 ||\n\t\tbeta <= 0.0\n\t) {\n\t\treturn NaN;\n\t}\n\tif ( x < 0.0 || x === PINF ) {\n\t\treturn NINF;\n\t}\n\tif ( alpha === 0.0 ) {\n\t\t// Point mass at 0...\n\t\treturn ( x === 0.0 ) ? PINF : NINF;\n\t}\n\treturn ln( gammaDeriv( alpha, x * beta ) ) + ln( beta );\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 constantFunction = require( '@stdlib/utils-constant-function' );\nvar degenerate = require( '@stdlib/stats-base-dists-degenerate-logpdf' ).factory;\nvar isnan = require( '@stdlib/math-base-assert-is-nan' );\nvar ln = require( '@stdlib/math-base-special-ln' );\nvar NINF = require( '@stdlib/constants-float64-ninf' );\nvar PINF = require( '@stdlib/constants-float64-pinf' );\nvar gammaDeriv = require( './gamma_p_derivative.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for evaluating the logarithm of the probability density function (PDF) for a gamma distribution with shape parameter `alpha` and rate parameter `beta`.\n*\n* @param {NonNegativeNumber} alpha - shape parameter\n* @param {PositiveNumber} beta - rate parameter\n* @returns {Function} logPDF\n*\n* @example\n* var logpdf = factory( 3.0, 1.5 );\n*\n* var y = logpdf( 1.0 );\n* // returns ~-0.977\n*\n* y = logpdf( 4.0 );\n* // returns ~-2.704\n*/\nfunction factory( alpha, beta ) {\n\tif (\n\t\tisnan( alpha ) ||\n\t\tisnan( beta ) ||\n\t\talpha < 0.0 ||\n\t\tbeta <= 0.0\n\t) {\n\t\treturn constantFunction( NaN );\n\t}\n\tif ( alpha === 0.0 ) {\n\t\treturn degenerate( 0.0 );\n\t}\n\treturn logpdf;\n\n\t/**\n\t* Evaluates the logarithm of the probability density function (PDF) for a gamma distribution.\n\t*\n\t* @private\n\t* @param {number} x - input value\n\t* @returns {number} evaluated logPDF\n\t*\n\t* @example\n\t* var y = logpdf( -1.2 );\n\t* // returns <number>\n\t*/\n\tfunction logpdf( x ) {\n\t\tif ( isnan( x ) ) {\n\t\t\treturn NaN;\n\t\t}\n\t\tif ( x < 0.0 || x === PINF ) {\n\t\t\treturn NINF;\n\t\t}\n\t\treturn ln( gammaDeriv( alpha, x * beta ) ) + ln( beta );\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* Gamma distribution logarithm of probability density function (PDF).\n*\n* @module @stdlib/stats-base-dists-gamma-logpdf\n*\n* @example\n* var logpdf = require( '@stdlib/stats-base-dists-gamma-logpdf' );\n*\n* var y = logpdf( 2.0, 0.5, 1.0 );\n* // returns ~-2.919\n*\n* @example\n* var factory = require( '@stdlib/stats-base-dists-gamma-logpdf' ).factory;\n*\n* var logpdf = factory( 6.0, 7.0 );\n* var y = logpdf( 2.0 );\n* // returns ~-3.646\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
|
+
"mappings": "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",
|
|
6
|
+
"names": ["require_regularised_gamma_prefix", "__commonJSMin", "exports", "module", "lanczosSumExpGScaled", "gammaln", "gamma", "log1p", "sqrt", "abs", "exp", "pow", "max", "min", "ln", "MAX_LN", "MIN_LN", "G", "E", "regularisedGammaPrefix", "a", "z", "prefix", "amza", "agh", "alz", "amz", "sq", "d", "require_gamma_p_derivative", "__commonJSMin", "exports", "module", "gammaln", "exp", "ln", "PINF", "FLOAT64_MAX", "regularisedGammaPrefix", "gammaPDerivative", "a", "x", "f1", "require_main", "__commonJSMin", "exports", "module", "isnan", "ln", "PINF", "NINF", "gammaDeriv", "logpdf", "x", "alpha", "beta", "require_factory", "__commonJSMin", "exports", "module", "constantFunction", "degenerate", "isnan", "ln", "NINF", "PINF", "gammaDeriv", "factory", "alpha", "beta", "logpdf", "x", "setReadOnly", "main", "factory"]
|
|
7
|
+
}
|
package/docs/types/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -40,15 +40,15 @@
|
|
|
40
40
|
// MODULES //
|
|
41
41
|
|
|
42
42
|
var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );
|
|
43
|
-
var
|
|
43
|
+
var main = require( './main.js' );
|
|
44
44
|
var factory = require( './factory.js' );
|
|
45
45
|
|
|
46
46
|
|
|
47
47
|
// MAIN //
|
|
48
48
|
|
|
49
|
-
setReadOnly(
|
|
49
|
+
setReadOnly( main, 'factory', factory );
|
|
50
50
|
|
|
51
51
|
|
|
52
52
|
// EXPORTS //
|
|
53
53
|
|
|
54
|
-
module.exports =
|
|
54
|
+
module.exports = main;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stdlib/stats-base-dists-gamma-logpdf",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Gamma distribution logarithm of probability density function (PDF).",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
@@ -37,36 +37,37 @@
|
|
|
37
37
|
"url": "https://github.com/stdlib-js/stdlib/issues"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@stdlib/constants-float64-e": "^0.0
|
|
41
|
-
"@stdlib/constants-float64-gamma-lanczos-g": "^0.0
|
|
42
|
-
"@stdlib/constants-float64-max": "^0.0
|
|
43
|
-
"@stdlib/constants-float64-max-ln": "^0.0
|
|
44
|
-
"@stdlib/constants-float64-min-ln": "^0.0
|
|
45
|
-
"@stdlib/constants-float64-ninf": "^0.0
|
|
46
|
-
"@stdlib/constants-float64-pinf": "^0.0
|
|
47
|
-
"@stdlib/math-base-assert-is-nan": "^0.0
|
|
48
|
-
"@stdlib/math-base-special-abs": "^0.0
|
|
49
|
-
"@stdlib/math-base-special-exp": "^0.0
|
|
50
|
-
"@stdlib/math-base-special-gamma": "^0.0
|
|
51
|
-
"@stdlib/math-base-special-gamma-lanczos-sum-expg-scaled": "^0.0
|
|
52
|
-
"@stdlib/math-base-special-gammaln": "^0.0
|
|
53
|
-
"@stdlib/math-base-special-ln": "^0.0
|
|
54
|
-
"@stdlib/math-base-special-log1p": "^0.0
|
|
55
|
-
"@stdlib/math-base-special-max": "^0.0
|
|
56
|
-
"@stdlib/math-base-special-min": "^0.0
|
|
57
|
-
"@stdlib/math-base-special-pow": "^0.0
|
|
58
|
-
"@stdlib/math-base-special-sqrt": "^0.0
|
|
59
|
-
"@stdlib/stats-base-dists-degenerate-logpdf": "^0.0
|
|
60
|
-
"@stdlib/utils-constant-function": "^0.0
|
|
61
|
-
"@stdlib/utils-define-nonenumerable-read-only-property": "^0.0
|
|
40
|
+
"@stdlib/constants-float64-e": "^0.2.0",
|
|
41
|
+
"@stdlib/constants-float64-gamma-lanczos-g": "^0.2.0",
|
|
42
|
+
"@stdlib/constants-float64-max": "^0.2.0",
|
|
43
|
+
"@stdlib/constants-float64-max-ln": "^0.2.0",
|
|
44
|
+
"@stdlib/constants-float64-min-ln": "^0.2.0",
|
|
45
|
+
"@stdlib/constants-float64-ninf": "^0.2.0",
|
|
46
|
+
"@stdlib/constants-float64-pinf": "^0.2.0",
|
|
47
|
+
"@stdlib/math-base-assert-is-nan": "^0.2.0",
|
|
48
|
+
"@stdlib/math-base-special-abs": "^0.2.0",
|
|
49
|
+
"@stdlib/math-base-special-exp": "^0.2.0",
|
|
50
|
+
"@stdlib/math-base-special-gamma": "^0.2.0",
|
|
51
|
+
"@stdlib/math-base-special-gamma-lanczos-sum-expg-scaled": "^0.2.0",
|
|
52
|
+
"@stdlib/math-base-special-gammaln": "^0.2.0",
|
|
53
|
+
"@stdlib/math-base-special-ln": "^0.2.0",
|
|
54
|
+
"@stdlib/math-base-special-log1p": "^0.2.0",
|
|
55
|
+
"@stdlib/math-base-special-max": "^0.2.0",
|
|
56
|
+
"@stdlib/math-base-special-min": "^0.2.0",
|
|
57
|
+
"@stdlib/math-base-special-pow": "^0.2.0",
|
|
58
|
+
"@stdlib/math-base-special-sqrt": "^0.2.0",
|
|
59
|
+
"@stdlib/stats-base-dists-degenerate-logpdf": "^0.2.0",
|
|
60
|
+
"@stdlib/utils-constant-function": "^0.2.0",
|
|
61
|
+
"@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.0"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@stdlib/
|
|
65
|
-
"@stdlib/
|
|
66
|
-
"@stdlib/random-base-randu": "^0.0.x",
|
|
64
|
+
"@stdlib/constants-float64-eps": "^0.2.0",
|
|
65
|
+
"@stdlib/random-base-randu": "^0.1.0",
|
|
67
66
|
"tape": "git+https://github.com/kgryte/tape.git#fix/globby",
|
|
68
67
|
"istanbul": "^0.4.1",
|
|
69
|
-
"tap-
|
|
68
|
+
"tap-min": "git+https://github.com/Planeshifter/tap-min.git",
|
|
69
|
+
"@stdlib/bench-harness": "^0.2.0",
|
|
70
|
+
"@stdlib/bench": "^0.3.1"
|
|
70
71
|
},
|
|
71
72
|
"engines": {
|
|
72
73
|
"node": ">=0.10.0",
|
|
@@ -99,7 +100,7 @@
|
|
|
99
100
|
"continuous"
|
|
100
101
|
],
|
|
101
102
|
"funding": {
|
|
102
|
-
"type": "
|
|
103
|
-
"url": "https://
|
|
103
|
+
"type": "opencollective",
|
|
104
|
+
"url": "https://opencollective.com/stdlib"
|
|
104
105
|
}
|
|
105
106
|
}
|
package/docs/repl.txt
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
{{alias}}( x, α, β )
|
|
3
|
-
Evaluates the logarithm of the probability density function (PDF) for a
|
|
4
|
-
gamma distribution with shape parameter `α` and rate parameter `β` at a
|
|
5
|
-
value `x`.
|
|
6
|
-
|
|
7
|
-
If `α < 0` or `β <= 0`, the function returns `NaN`.
|
|
8
|
-
|
|
9
|
-
If provided `NaN` as any argument, the function returns `NaN`.
|
|
10
|
-
|
|
11
|
-
Parameters
|
|
12
|
-
----------
|
|
13
|
-
x: number
|
|
14
|
-
Input value.
|
|
15
|
-
|
|
16
|
-
α: number
|
|
17
|
-
Shape parameter.
|
|
18
|
-
|
|
19
|
-
β: number
|
|
20
|
-
Rate parameter.
|
|
21
|
-
|
|
22
|
-
Returns
|
|
23
|
-
-------
|
|
24
|
-
out: number
|
|
25
|
-
Evaluated logPDF.
|
|
26
|
-
|
|
27
|
-
Examples
|
|
28
|
-
--------
|
|
29
|
-
> var y = {{alias}}( 2.0, 0.5, 1.0 )
|
|
30
|
-
~-2.919
|
|
31
|
-
> y = {{alias}}( 0.1, 1.0, 1.0 )
|
|
32
|
-
~-0.1
|
|
33
|
-
> y = {{alias}}( -1.0, 4.0, 2.0 )
|
|
34
|
-
-Infinity
|
|
35
|
-
|
|
36
|
-
> y = {{alias}}( NaN, 0.6, 1.0 )
|
|
37
|
-
NaN
|
|
38
|
-
> y = {{alias}}( 0.0, NaN, 1.0 )
|
|
39
|
-
NaN
|
|
40
|
-
> y = {{alias}}( 0.0, 1.0, NaN )
|
|
41
|
-
NaN
|
|
42
|
-
|
|
43
|
-
// Negative shape parameter:
|
|
44
|
-
> y = {{alias}}( 2.0, -1.0, 1.0 )
|
|
45
|
-
NaN
|
|
46
|
-
// Non-positive rate parameter:
|
|
47
|
-
> y = {{alias}}( 2.0, 1.0, -1.0 )
|
|
48
|
-
NaN
|
|
49
|
-
|
|
50
|
-
// Degenerate distribution centered at `0.0` when `α = 0.0`:
|
|
51
|
-
> y = {{alias}}( 2.0, 0.0, 2.0 )
|
|
52
|
-
-Infinity
|
|
53
|
-
> y = {{alias}}( 0.0, 0.0, 2.0 )
|
|
54
|
-
Infinity
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
{{alias}}.factory( α, β )
|
|
58
|
-
Returns a function for evaluating the logarithm of the probability density
|
|
59
|
-
function (PDF) of a gamma distribution with shape parameter `α` and rate
|
|
60
|
-
parameter `β`.
|
|
61
|
-
|
|
62
|
-
Parameters
|
|
63
|
-
----------
|
|
64
|
-
α: number
|
|
65
|
-
Shape parameter.
|
|
66
|
-
|
|
67
|
-
β: number
|
|
68
|
-
Rate parameter.
|
|
69
|
-
|
|
70
|
-
Returns
|
|
71
|
-
-------
|
|
72
|
-
logpdf: Function
|
|
73
|
-
Logarithm of probability density function (PDF).
|
|
74
|
-
|
|
75
|
-
Examples
|
|
76
|
-
--------
|
|
77
|
-
> var mylogPDF = {{alias}}.factory( 6.0, 7.0 );
|
|
78
|
-
> var y = mylogPDF( 2.0 )
|
|
79
|
-
~-3.646
|
|
80
|
-
|
|
81
|
-
See Also
|
|
82
|
-
--------
|
|
83
|
-
|
package/docs/types/test.ts
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @license Apache-2.0
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2019 The Stdlib Authors.
|
|
5
|
-
*
|
|
6
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
-
* you may not use this file except in compliance with the License.
|
|
8
|
-
* You may obtain a copy of the License at
|
|
9
|
-
*
|
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
*
|
|
12
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
-
* See the License for the specific language governing permissions and
|
|
16
|
-
* limitations under the License.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
import logpdf = require( './index' );
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
// TESTS //
|
|
23
|
-
|
|
24
|
-
// The function returns a number...
|
|
25
|
-
{
|
|
26
|
-
logpdf( 2, 2, 4 ); // $ExpectType number
|
|
27
|
-
logpdf( 1, 2, 8 ); // $ExpectType number
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// The compiler throws an error if the function is provided values other than three numbers...
|
|
31
|
-
{
|
|
32
|
-
logpdf( true, 3, 6 ); // $ExpectError
|
|
33
|
-
logpdf( false, 2, 4 ); // $ExpectError
|
|
34
|
-
logpdf( '5', 1, 2 ); // $ExpectError
|
|
35
|
-
logpdf( [], 1, 2 ); // $ExpectError
|
|
36
|
-
logpdf( {}, 2, 4 ); // $ExpectError
|
|
37
|
-
logpdf( ( x: number ): number => x, 2, 4 ); // $ExpectError
|
|
38
|
-
|
|
39
|
-
logpdf( 9, true, 12 ); // $ExpectError
|
|
40
|
-
logpdf( 9, false, 12 ); // $ExpectError
|
|
41
|
-
logpdf( 5, '5', 10 ); // $ExpectError
|
|
42
|
-
logpdf( 8, [], 16 ); // $ExpectError
|
|
43
|
-
logpdf( 9, {}, 18 ); // $ExpectError
|
|
44
|
-
logpdf( 8, ( x: number ): number => x, 16 ); // $ExpectError
|
|
45
|
-
|
|
46
|
-
logpdf( 9, 5, true ); // $ExpectError
|
|
47
|
-
logpdf( 9, 5, false ); // $ExpectError
|
|
48
|
-
logpdf( 5, 2, '5' ); // $ExpectError
|
|
49
|
-
logpdf( 8, 4, [] ); // $ExpectError
|
|
50
|
-
logpdf( 9, 4, {} ); // $ExpectError
|
|
51
|
-
logpdf( 8, 5, ( x: number ): number => x ); // $ExpectError
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// The compiler throws an error if the function is provided an unsupported number of arguments...
|
|
55
|
-
{
|
|
56
|
-
logpdf(); // $ExpectError
|
|
57
|
-
logpdf( 2 ); // $ExpectError
|
|
58
|
-
logpdf( 2, 0 ); // $ExpectError
|
|
59
|
-
logpdf( 2, 0, 4, 1 ); // $ExpectError
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// Attached to main export is a `factory` method which returns a function...
|
|
63
|
-
{
|
|
64
|
-
logpdf.factory( 3, 4 ); // $ExpectType Unary
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// The `factory` method returns a function which returns a number...
|
|
68
|
-
{
|
|
69
|
-
const fcn = logpdf.factory( 3, 4 );
|
|
70
|
-
fcn( 2 ); // $ExpectType number
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// The compiler throws an error if the function returned by the `factory` method is provided invalid arguments...
|
|
74
|
-
{
|
|
75
|
-
const fcn = logpdf.factory( 3, 4 );
|
|
76
|
-
fcn( true ); // $ExpectError
|
|
77
|
-
fcn( false ); // $ExpectError
|
|
78
|
-
fcn( '5' ); // $ExpectError
|
|
79
|
-
fcn( [] ); // $ExpectError
|
|
80
|
-
fcn( {} ); // $ExpectError
|
|
81
|
-
fcn( ( x: number ): number => x ); // $ExpectError
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// The compiler throws an error if the function returned by the `factory` method is provided an unsupported number of arguments...
|
|
85
|
-
{
|
|
86
|
-
const fcn = logpdf.factory( 3, 4 );
|
|
87
|
-
fcn(); // $ExpectError
|
|
88
|
-
fcn( 2, 0 ); // $ExpectError
|
|
89
|
-
fcn( 2, 0, 1 ); // $ExpectError
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// The compiler throws an error if the `factory` method is provided values other than two numbers...
|
|
93
|
-
{
|
|
94
|
-
logpdf.factory( true, 3 ); // $ExpectError
|
|
95
|
-
logpdf.factory( false, 2 ); // $ExpectError
|
|
96
|
-
logpdf.factory( '5', 1 ); // $ExpectError
|
|
97
|
-
logpdf.factory( [], 1 ); // $ExpectError
|
|
98
|
-
logpdf.factory( {}, 2 ); // $ExpectError
|
|
99
|
-
logpdf.factory( ( x: number ): number => x, 2 ); // $ExpectError
|
|
100
|
-
|
|
101
|
-
logpdf.factory( 9, true ); // $ExpectError
|
|
102
|
-
logpdf.factory( 9, false ); // $ExpectError
|
|
103
|
-
logpdf.factory( 5, '5' ); // $ExpectError
|
|
104
|
-
logpdf.factory( 8, [] ); // $ExpectError
|
|
105
|
-
logpdf.factory( 9, {} ); // $ExpectError
|
|
106
|
-
logpdf.factory( 8, ( x: number ): number => x ); // $ExpectError
|
|
107
|
-
|
|
108
|
-
logpdf.factory( [], true ); // $ExpectError
|
|
109
|
-
logpdf.factory( {}, false ); // $ExpectError
|
|
110
|
-
logpdf.factory( false, '5' ); // $ExpectError
|
|
111
|
-
logpdf.factory( {}, [] ); // $ExpectError
|
|
112
|
-
logpdf.factory( '5', ( x: number ): number => x ); // $ExpectError
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// The compiler throws an error if the `factory` method is provided an unsupported number of arguments...
|
|
116
|
-
{
|
|
117
|
-
logpdf.factory( 0 ); // $ExpectError
|
|
118
|
-
logpdf.factory( 0, 4, 8 ); // $ExpectError
|
|
119
|
-
}
|
|
File without changes
|