@stdlib/stats-base-dists-levy-entropy 0.2.2 → 0.3.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 CHANGED
@@ -1 +1 @@
1
- Copyright (c) 2016-2024 The Stdlib Authors.
1
+ Copyright (c) 2016-2026 The Stdlib Authors.
package/README.md CHANGED
@@ -152,6 +152,101 @@ for ( i = 0; i < 10; i++ ) {
152
152
 
153
153
  <!-- /.examples -->
154
154
 
155
+ <!-- C interface documentation. -->
156
+
157
+ * * *
158
+
159
+ <section class="c">
160
+
161
+ ## C APIs
162
+
163
+ <!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
164
+
165
+ <section class="intro">
166
+
167
+ </section>
168
+
169
+ <!-- /.intro -->
170
+
171
+ <!-- C usage documentation. -->
172
+
173
+ <section class="usage">
174
+
175
+ ### Usage
176
+
177
+ ```c
178
+ #include "stdlib/stats/base/dists/levy/entropy.h"
179
+ ```
180
+
181
+ #### stdlib_base_dists_levy_entropy( mu, c )
182
+
183
+ Returns the [entropy][entropy] for a [Lévy][levy-distribution] distribution with location parameter `mu` and scale parameter `c`.
184
+
185
+ ```c
186
+ double out = stdlib_base_dists_levy_entropy( 0.0, 1.0 );
187
+ // returns ~3.324
188
+ ```
189
+
190
+ The function accepts the following arguments:
191
+
192
+ - **mu**: `[in] double` location parameter.
193
+ - **c**: `[in] double` scale parameter.
194
+
195
+ ```c
196
+ double stdlib_base_dists_levy_entropy( const double mu, const double c );
197
+ ```
198
+
199
+ </section>
200
+
201
+ <!-- /.usage -->
202
+
203
+ <!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
204
+
205
+ <section class="notes">
206
+
207
+ </section>
208
+
209
+ <!-- /.notes -->
210
+
211
+ <!-- C API usage examples. -->
212
+
213
+ <section class="examples">
214
+
215
+ ### Examples
216
+
217
+ ```c
218
+ #include "stdlib/stats/base/dists/levy/entropy.h"
219
+ #include <stdlib.h>
220
+ #include <stdio.h>
221
+
222
+ static double random_uniform( const double min, const double max ) {
223
+ double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
224
+ return min + ( v*(max-min) );
225
+ }
226
+
227
+ int main( void ) {
228
+ double mu;
229
+ double c;
230
+ double y;
231
+ int i;
232
+
233
+ for ( i = 0; i < 25; i++ ) {
234
+ mu = random_uniform( -5.0, 5.0 );
235
+ c = random_uniform( 0.0, 20.0 );
236
+ y = stdlib_base_dists_levy_entropy( mu, c );
237
+ printf( "mu = %lf; c = %lf; h(X;µ,c) = %lf\n", mu, c, y );
238
+ }
239
+ }
240
+ ```
241
+
242
+ </section>
243
+
244
+ <!-- /.examples -->
245
+
246
+ </section>
247
+
248
+ <!-- /.c -->
249
+
155
250
  <!-- 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. -->
156
251
 
157
252
  <section class="references">
@@ -194,7 +289,7 @@ See [LICENSE][stdlib-license].
194
289
 
195
290
  ## Copyright
196
291
 
197
- Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
292
+ Copyright &copy; 2016-2026. The Stdlib [Authors][stdlib-authors].
198
293
 
199
294
  </section>
200
295
 
@@ -207,8 +302,8 @@ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
207
302
  [npm-image]: http://img.shields.io/npm/v/@stdlib/stats-base-dists-levy-entropy.svg
208
303
  [npm-url]: https://npmjs.org/package/@stdlib/stats-base-dists-levy-entropy
209
304
 
210
- [test-image]: https://github.com/stdlib-js/stats-base-dists-levy-entropy/actions/workflows/test.yml/badge.svg?branch=v0.2.2
211
- [test-url]: https://github.com/stdlib-js/stats-base-dists-levy-entropy/actions/workflows/test.yml?query=branch:v0.2.2
305
+ [test-image]: https://github.com/stdlib-js/stats-base-dists-levy-entropy/actions/workflows/test.yml/badge.svg?branch=v0.3.0
306
+ [test-url]: https://github.com/stdlib-js/stats-base-dists-levy-entropy/actions/workflows/test.yml?query=branch:v0.3.0
212
307
 
213
308
  [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/stats-base-dists-levy-entropy/main.svg
214
309
  [coverage-url]: https://codecov.io/github/stdlib-js/stats-base-dists-levy-entropy?branch=main
@@ -220,8 +315,8 @@ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
220
315
 
221
316
  -->
222
317
 
223
- [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
224
- [chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
318
+ [chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
319
+ [chat-url]: https://stdlib.zulipchat.com
225
320
 
226
321
  [stdlib]: https://github.com/stdlib-js/stdlib
227
322
 
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- "use strict";var a=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var u=a(function(p,t){
2
- var i=require('@stdlib/math-base-assert-is-nan/dist'),n=require('@stdlib/math-base-special-ln/dist'),s=require('@stdlib/constants-float64-eulergamma/dist'),v=require('@stdlib/constants-float64-pi/dist'),q=3*s;function o(e,r){return i(e)||i(r)||r<=0?NaN:(1+q+n(16*r*r*v))/2}t.exports=o
3
- });var A=u();module.exports=A;
1
+ "use strict";var u=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var t=u(function(A,a){
2
+ var i=require('@stdlib/math-base-assert-is-nan/dist'),n=require('@stdlib/math-base-special-ln/dist'),s=require('@stdlib/constants-float64-eulergamma/dist'),v=require('@stdlib/constants-float64-pi/dist'),E=1+3*s,q=16*v;function M(e,r){return i(e)||i(r)||r<=0?NaN:(E+n(r*r*q))/2}a.exports=M
3
+ });var _=t();module.exports=_;
4
4
  /** @license Apache-2.0 */
5
5
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../lib/main.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 isnan = require( '@stdlib/math-base-assert-is-nan' );\nvar ln = require( '@stdlib/math-base-special-ln' );\nvar GAMMA = require( '@stdlib/constants-float64-eulergamma' );\nvar PI = require( '@stdlib/constants-float64-pi' );\n\n\n// VARIABLES //\n\nvar THREE_GAMMA = 3.0 * GAMMA;\n\n\n// MAIN //\n\n/**\n* Returns the differential entropy for a L\u00E9vy distribution with location `mu` and scale `s`.\n*\n* @param {number} mu - location parameter\n* @param {PositiveNumber} c - scale parameter\n* @returns {number} entropy\n*\n* @example\n* var y = entropy( 0.0, 1.0 );\n* // returns ~3.324\n*\n* @example\n* var y = entropy( 5.0, 2.0 );\n* // returns ~4.018\n*\n* @example\n* var y = entropy( NaN, 1.0 );\n* // returns NaN\n*\n* @example\n* var y = entropy( 0.0, NaN );\n* // returns NaN\n*\n* @example\n* var y = entropy( 0.0, 0.0 );\n* // returns NaN\n*/\nfunction entropy( mu, c ) {\n\tif (\n\t\tisnan( mu ) ||\n\t\tisnan( c ) ||\n\t\tc <= 0.0\n\t) {\n\t\treturn NaN;\n\t}\n\treturn ( 1.0 + THREE_GAMMA + ln( 16.0*c*c*PI ) ) / 2.0;\n}\n\n\n// EXPORTS //\n\nmodule.exports = entropy;\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* L\u00E9vy distribution differential entropy.\n*\n* @module @stdlib/stats-base-dists-levy-entropy\n*\n* @example\n* var entropy = require( '@stdlib/stats-base-dists-levy-entropy' );\n*\n* var y = entropy( 0.0, 1.0 );\n* // returns ~3.324\n*\n* y = entropy( 4.0, 2.0 );\n* // returns ~4.018\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
5
- "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAQ,QAAS,iCAAkC,EACnDC,EAAK,QAAS,8BAA+B,EAC7CC,EAAQ,QAAS,sCAAuC,EACxDC,EAAK,QAAS,8BAA+B,EAK7CC,EAAc,EAAMF,EAgCxB,SAASG,EAASC,EAAIC,EAAI,CACzB,OACCP,EAAOM,CAAG,GACVN,EAAOO,CAAE,GACTA,GAAK,EAEE,KAEC,EAAMH,EAAcH,EAAI,GAAKM,EAAEA,EAAEJ,CAAG,GAAM,CACpD,CAKAJ,EAAO,QAAUM,ICvCjB,IAAIG,EAAO,IAKX,OAAO,QAAUA",
6
- "names": ["require_main", "__commonJSMin", "exports", "module", "isnan", "ln", "GAMMA", "PI", "THREE_GAMMA", "entropy", "mu", "c", "main"]
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 isnan = require( '@stdlib/math-base-assert-is-nan' );\nvar ln = require( '@stdlib/math-base-special-ln' );\nvar GAMMA = require( '@stdlib/constants-float64-eulergamma' );\nvar PI = require( '@stdlib/constants-float64-pi' );\n\n\n// VARIABLES //\n\nvar ONE_PLUS_THREE_GAMMA = 1.0 + ( 3.0 * GAMMA );\nvar PI_TIMES_SIXTEEN = 16.0 * PI;\n\n\n// MAIN //\n\n/**\n* Returns the differential entropy for a L\u00E9vy distribution with location `mu` and scale `s`.\n*\n* @param {number} mu - location parameter\n* @param {PositiveNumber} c - scale parameter\n* @returns {number} entropy\n*\n* @example\n* var y = entropy( 0.0, 1.0 );\n* // returns ~3.324\n*\n* @example\n* var y = entropy( 5.0, 2.0 );\n* // returns ~4.018\n*\n* @example\n* var y = entropy( NaN, 1.0 );\n* // returns NaN\n*\n* @example\n* var y = entropy( 0.0, NaN );\n* // returns NaN\n*\n* @example\n* var y = entropy( 0.0, 0.0 );\n* // returns NaN\n*/\nfunction entropy( mu, c ) {\n\tif (\n\t\tisnan( mu ) ||\n\t\tisnan( c ) ||\n\t\tc <= 0.0\n\t) {\n\t\treturn NaN;\n\t}\n\treturn ( ONE_PLUS_THREE_GAMMA + ln( c*c*PI_TIMES_SIXTEEN ) ) / 2.0;\n}\n\n\n// EXPORTS //\n\nmodule.exports = entropy;\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* L\u00E9vy distribution differential entropy.\n*\n* @module @stdlib/stats-base-dists-levy-entropy\n*\n* @example\n* var entropy = require( '@stdlib/stats-base-dists-levy-entropy' );\n*\n* var y = entropy( 0.0, 1.0 );\n* // returns ~3.324\n*\n* y = entropy( 4.0, 2.0 );\n* // returns ~4.018\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
5
+ "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAQ,QAAS,iCAAkC,EACnDC,EAAK,QAAS,8BAA+B,EAC7CC,EAAQ,QAAS,sCAAuC,EACxDC,EAAK,QAAS,8BAA+B,EAK7CC,EAAuB,EAAQ,EAAMF,EACrCG,EAAmB,GAAOF,EAgC9B,SAASG,EAASC,EAAIC,EAAI,CACzB,OACCR,EAAOO,CAAG,GACVP,EAAOQ,CAAE,GACTA,GAAK,EAEE,KAECJ,EAAuBH,EAAIO,EAAEA,EAAEH,CAAiB,GAAM,CAChE,CAKAN,EAAO,QAAUO,ICxCjB,IAAIG,EAAO,IAKX,OAAO,QAAUA",
6
+ "names": ["require_main", "__commonJSMin", "exports", "module", "isnan", "ln", "GAMMA", "PI", "ONE_PLUS_THREE_GAMMA", "PI_TIMES_SIXTEEN", "entropy", "mu", "c", "main"]
7
7
  }
@@ -0,0 +1,38 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2025 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
+ #ifndef STDLIB_STATS_BASE_DISTS_LEVY_ENTROPY_H
20
+ #define STDLIB_STATS_BASE_DISTS_LEVY_ENTROPY_H
21
+
22
+ /*
23
+ * If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler.
24
+ */
25
+ #ifdef __cplusplus
26
+ extern "C" {
27
+ #endif
28
+
29
+ /**
30
+ * Returns the differentaial entropy for a Lévy distribution with location `mu` and scale `c`.
31
+ */
32
+ double stdlib_base_dists_levy_entropy( const double mu, const double c );
33
+
34
+ #ifdef __cplusplus
35
+ }
36
+ #endif
37
+
38
+ #endif // !STDLIB_STATS_BASE_DISTS_LEVY_ENTROPY_H
package/lib/main.js CHANGED
@@ -28,7 +28,8 @@ var PI = require( '@stdlib/constants-float64-pi' );
28
28
 
29
29
  // VARIABLES //
30
30
 
31
- var THREE_GAMMA = 3.0 * GAMMA;
31
+ var ONE_PLUS_THREE_GAMMA = 1.0 + ( 3.0 * GAMMA );
32
+ var PI_TIMES_SIXTEEN = 16.0 * PI;
32
33
 
33
34
 
34
35
  // MAIN //
@@ -68,7 +69,7 @@ function entropy( mu, c ) {
68
69
  ) {
69
70
  return NaN;
70
71
  }
71
- return ( 1.0 + THREE_GAMMA + ln( 16.0*c*c*PI ) ) / 2.0;
72
+ return ( ONE_PLUS_THREE_GAMMA + ln( c*c*PI_TIMES_SIXTEEN ) ) / 2.0;
72
73
  }
73
74
 
74
75
 
package/lib/native.js ADDED
@@ -0,0 +1,63 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2025 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
+ 'use strict';
20
+
21
+ // MODULES //
22
+
23
+ var addon = require( './../src/addon.node' );
24
+
25
+
26
+ // MAIN //
27
+
28
+ /**
29
+ * Returns the differential entropy for a Lévy distribution with location `mu` and scale `c`.
30
+ *
31
+ * @private
32
+ * @param {number} mu - location parameter
33
+ * @param {PositiveNumber} c - scale parameter
34
+ * @returns {PositiveNumber} differential entropy
35
+ *
36
+ * @example
37
+ * var y = entropy( 0.0, 1.0 );
38
+ * // returns ~3.324
39
+ *
40
+ * @example
41
+ * var y = entropy( 5.0, 2.0 );
42
+ * // returns ~4.018
43
+ *
44
+ * @example
45
+ * var y = entropy( NaN, 1.0 );
46
+ * // returns NaN
47
+ *
48
+ * @example
49
+ * var y = entropy( 0.0, NaN );
50
+ * // returns NaN
51
+ *
52
+ * @example
53
+ * var y = entropy( 0.0, 0.0 );
54
+ * // returns NaN
55
+ */
56
+ function entropy( mu, c ) {
57
+ return addon( mu, c );
58
+ }
59
+
60
+
61
+ // EXPORTS //
62
+
63
+ module.exports = entropy;
package/manifest.json ADDED
@@ -0,0 +1,86 @@
1
+ {
2
+ "options": {
3
+ "task": "build",
4
+ "wasm": false
5
+ },
6
+ "fields": [
7
+ {
8
+ "field": "src",
9
+ "resolve": true,
10
+ "relative": true
11
+ },
12
+ {
13
+ "field": "include",
14
+ "resolve": true,
15
+ "relative": true
16
+ },
17
+ {
18
+ "field": "libraries",
19
+ "resolve": false,
20
+ "relative": false
21
+ },
22
+ {
23
+ "field": "libpath",
24
+ "resolve": true,
25
+ "relative": false
26
+ }
27
+ ],
28
+ "confs": [
29
+ {
30
+ "task": "build",
31
+ "wasm": false,
32
+ "src": [
33
+ "./src/main.c"
34
+ ],
35
+ "include": [
36
+ "./include"
37
+ ],
38
+ "libraries": [],
39
+ "libpath": [],
40
+ "dependencies": [
41
+ "@stdlib/math-base-napi-binary",
42
+ "@stdlib/math-base-assert-is-nan",
43
+ "@stdlib/math-base-special-ln",
44
+ "@stdlib/constants-float64-eulergamma",
45
+ "@stdlib/constants-float64-pi"
46
+ ]
47
+ },
48
+ {
49
+ "task": "benchmark",
50
+ "wasm": false,
51
+ "src": [
52
+ "./src/main.c"
53
+ ],
54
+ "include": [
55
+ "./include"
56
+ ],
57
+ "libraries": [],
58
+ "libpath": [],
59
+ "dependencies": [
60
+ "@stdlib/math-base-assert-is-nan",
61
+ "@stdlib/math-base-special-ln",
62
+ "@stdlib/constants-float64-eulergamma",
63
+ "@stdlib/constants-float64-pi",
64
+ "@stdlib/constants-float64-eps"
65
+ ]
66
+ },
67
+ {
68
+ "task": "examples",
69
+ "wasm": false,
70
+ "src": [
71
+ "./src/main.c"
72
+ ],
73
+ "include": [
74
+ "./include"
75
+ ],
76
+ "libraries": [],
77
+ "libpath": [],
78
+ "dependencies": [
79
+ "@stdlib/math-base-assert-is-nan",
80
+ "@stdlib/math-base-special-ln",
81
+ "@stdlib/constants-float64-eulergamma",
82
+ "@stdlib/constants-float64-pi"
83
+ ]
84
+ }
85
+ ]
86
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stdlib/stats-base-dists-levy-entropy",
3
- "version": "0.2.2",
3
+ "version": "0.3.0",
4
4
  "description": "Lévy distribution entropy.",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -14,9 +14,12 @@
14
14
  }
15
15
  ],
16
16
  "main": "./lib",
17
+ "gypfile": false,
17
18
  "directories": {
18
19
  "doc": "./docs",
20
+ "include": "./include",
19
21
  "lib": "./lib",
22
+ "src": "./src",
20
23
  "dist": "./dist"
21
24
  },
22
25
  "types": "./docs/types",
@@ -33,7 +36,9 @@
33
36
  "@stdlib/constants-float64-eulergamma": "^0.2.2",
34
37
  "@stdlib/constants-float64-pi": "^0.2.2",
35
38
  "@stdlib/math-base-assert-is-nan": "^0.2.2",
36
- "@stdlib/math-base-special-ln": "^0.2.3"
39
+ "@stdlib/math-base-napi-binary": "^0.3.1",
40
+ "@stdlib/math-base-special-ln": "^0.2.4",
41
+ "@stdlib/utils-library-manifest": "^0.2.3"
37
42
  },
38
43
  "devDependencies": {},
39
44
  "engines": {
package/src/addon.c ADDED
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2025 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
+ #include "stdlib/stats/base/dists/levy/entropy.h"
20
+ #include "stdlib/math/base/napi/binary.h"
21
+
22
+ STDLIB_MATH_BASE_NAPI_MODULE_DD_D( stdlib_base_dists_levy_entropy )
package/src/main.c ADDED
@@ -0,0 +1,48 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2025 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
+ #include "stdlib/stats/base/dists/levy/entropy.h"
20
+ #include "stdlib/math/base/assert/is_nan.h"
21
+ #include "stdlib/math/base/special/ln.h"
22
+ #include "stdlib/constants/float64/eulergamma.h"
23
+ #include "stdlib/constants/float64/pi.h"
24
+
25
+ static const double ONE_PLUS_THREE_GAMMA = 1.0 + ( 3.0 * STDLIB_CONSTANT_FLOAT64_EULERGAMMA );
26
+ static const double PI_TIMES_SIXTEEN = 16.0 * STDLIB_CONSTANT_FLOAT64_PI;
27
+
28
+ /**
29
+ * Returns the differential entropy for a Lévy distribution with location `mu` and scale `c`.
30
+ *
31
+ * @param mu location parameter
32
+ * @param c scale parameter
33
+ * @return differential entropy
34
+ *
35
+ * @example
36
+ * double y = stdlib_base_dists_levy_entropy( 0.0, 1.0 );
37
+ * // returns ~3.324
38
+ */
39
+ double stdlib_base_dists_levy_entropy( const double mu, const double c ) {
40
+ if (
41
+ stdlib_base_is_nan( mu ) ||
42
+ stdlib_base_is_nan( c ) ||
43
+ c <= 0.0
44
+ ) {
45
+ return 0.0/0.0; // NaN
46
+ }
47
+ return ( ONE_PLUS_THREE_GAMMA + stdlib_base_ln( c*c*PI_TIMES_SIXTEEN ) ) / 2.0;
48
+ }