@stdlib/stats-base-dists-normal-mgf 0.2.1 → 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 +1 -1
- package/README.md +113 -18
- package/include/stdlib/stats/base/dists/normal/mgf.h +38 -0
- package/lib/native.js +72 -0
- package/manifest.json +84 -0
- package/package.json +11 -6
- package/src/addon.c +22 -0
- package/src/main.c +46 -0
package/NOTICE
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Copyright (c) 2016-
|
|
1
|
+
Copyright (c) 2016-2026 The Stdlib Authors.
|
package/README.md
CHANGED
|
@@ -149,21 +149,112 @@ y = mymgf( 0.5 );
|
|
|
149
149
|
<!-- eslint no-undef: "error" -->
|
|
150
150
|
|
|
151
151
|
```javascript
|
|
152
|
-
var
|
|
152
|
+
var uniform = require( '@stdlib/random-array-uniform' );
|
|
153
|
+
var logEachMap = require( '@stdlib/console-log-each-map' );
|
|
153
154
|
var mgf = require( '@stdlib/stats-base-dists-normal-mgf' );
|
|
154
155
|
|
|
155
|
-
var
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
var
|
|
159
|
-
var
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
156
|
+
var opts = {
|
|
157
|
+
'dtype': 'float64'
|
|
158
|
+
};
|
|
159
|
+
var sigma = uniform( 10, 0.0, 20.0, opts );
|
|
160
|
+
var mu = uniform( 10, -5.0, 5.0, opts );
|
|
161
|
+
var t = uniform( 10, 0.0, 10.0, opts );
|
|
162
|
+
|
|
163
|
+
logEachMap( 't: %0.4f, µ: %0.4f, σ: %0.4f, M_X(t;µ,σ): %0.4f', t, mu, sigma, mgf );
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
</section>
|
|
167
|
+
|
|
168
|
+
<!-- /.examples -->
|
|
169
|
+
|
|
170
|
+
<!-- C interface documentation. -->
|
|
171
|
+
|
|
172
|
+
* * *
|
|
173
|
+
|
|
174
|
+
<section class="c">
|
|
175
|
+
|
|
176
|
+
## C APIs
|
|
177
|
+
|
|
178
|
+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
|
|
179
|
+
|
|
180
|
+
<section class="intro">
|
|
181
|
+
|
|
182
|
+
</section>
|
|
183
|
+
|
|
184
|
+
<!-- /.intro -->
|
|
185
|
+
|
|
186
|
+
<!-- C usage documentation. -->
|
|
187
|
+
|
|
188
|
+
<section class="usage">
|
|
189
|
+
|
|
190
|
+
### Usage
|
|
191
|
+
|
|
192
|
+
```c
|
|
193
|
+
#include "stdlib/stats/base/dists/normal/mgf.h"
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
#### stdlib_base_dists_normal_mgf( t, mu, sigma )
|
|
197
|
+
|
|
198
|
+
Evaluates the [moment-generating function][mgf] (MGF) for a [normal][normal-distribution] distribution with parameters `mu` (mean) and `sigma` (standard deviation).
|
|
199
|
+
|
|
200
|
+
```c
|
|
201
|
+
double y = stdlib_base_dists_normal_mgf( 2.0, 0.0, 1.0 );
|
|
202
|
+
// returns ~7.389
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
The function accepts the following arguments:
|
|
206
|
+
|
|
207
|
+
- **t**: `[in] double` input value.
|
|
208
|
+
- **mu**: `[in] double` mean.
|
|
209
|
+
- **sigma**: `[in] double` standard deviation.
|
|
210
|
+
|
|
211
|
+
```c
|
|
212
|
+
double stdlib_base_dists_normal_mgf( const double t, const double mu, const double sigma );
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
</section>
|
|
216
|
+
|
|
217
|
+
<!-- /.usage -->
|
|
218
|
+
|
|
219
|
+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
|
220
|
+
|
|
221
|
+
<section class="notes">
|
|
222
|
+
|
|
223
|
+
</section>
|
|
224
|
+
|
|
225
|
+
<!-- /.notes -->
|
|
226
|
+
|
|
227
|
+
<!-- C API usage examples. -->
|
|
228
|
+
|
|
229
|
+
<section class="examples">
|
|
230
|
+
|
|
231
|
+
### Examples
|
|
232
|
+
|
|
233
|
+
```c
|
|
234
|
+
#include "stdlib/stats/base/dists/normal/mgf.h"
|
|
235
|
+
#include "stdlib/constants/float64/eps.h"
|
|
236
|
+
#include <stdlib.h>
|
|
237
|
+
#include <stdio.h>
|
|
238
|
+
|
|
239
|
+
static double random_uniform( const double min, const double max ) {
|
|
240
|
+
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
|
|
241
|
+
return min + ( v*(max-min) );
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
int main( void ) {
|
|
245
|
+
double sigma;
|
|
246
|
+
double mu;
|
|
247
|
+
double t;
|
|
248
|
+
double y;
|
|
249
|
+
int i;
|
|
250
|
+
|
|
251
|
+
for ( i = 0; i < 10; i++ ) {
|
|
252
|
+
t = random_uniform( 0.0, 1.0 );
|
|
253
|
+
mu = random_uniform( -50.0, 50.0 );
|
|
254
|
+
sigma = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 20.0 );
|
|
255
|
+
y = stdlib_base_dists_normal_mgf( t, mu, sigma );
|
|
256
|
+
printf( "t: %lf, µ: %lf, σ: %lf, M_X(t;µ,σ): %lf\n", t, mu, sigma, y );
|
|
257
|
+
}
|
|
167
258
|
}
|
|
168
259
|
```
|
|
169
260
|
|
|
@@ -171,6 +262,10 @@ for ( i = 0; i < 10; i++ ) {
|
|
|
171
262
|
|
|
172
263
|
<!-- /.examples -->
|
|
173
264
|
|
|
265
|
+
</section>
|
|
266
|
+
|
|
267
|
+
<!-- /.c -->
|
|
268
|
+
|
|
174
269
|
<!-- 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. -->
|
|
175
270
|
|
|
176
271
|
<section class="references">
|
|
@@ -213,7 +308,7 @@ See [LICENSE][stdlib-license].
|
|
|
213
308
|
|
|
214
309
|
## Copyright
|
|
215
310
|
|
|
216
|
-
Copyright © 2016-
|
|
311
|
+
Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors].
|
|
217
312
|
|
|
218
313
|
</section>
|
|
219
314
|
|
|
@@ -226,8 +321,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
226
321
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/stats-base-dists-normal-mgf.svg
|
|
227
322
|
[npm-url]: https://npmjs.org/package/@stdlib/stats-base-dists-normal-mgf
|
|
228
323
|
|
|
229
|
-
[test-image]: https://github.com/stdlib-js/stats-base-dists-normal-mgf/actions/workflows/test.yml/badge.svg?branch=v0.
|
|
230
|
-
[test-url]: https://github.com/stdlib-js/stats-base-dists-normal-mgf/actions/workflows/test.yml?query=branch:v0.
|
|
324
|
+
[test-image]: https://github.com/stdlib-js/stats-base-dists-normal-mgf/actions/workflows/test.yml/badge.svg?branch=v0.3.0
|
|
325
|
+
[test-url]: https://github.com/stdlib-js/stats-base-dists-normal-mgf/actions/workflows/test.yml?query=branch:v0.3.0
|
|
231
326
|
|
|
232
327
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/stats-base-dists-normal-mgf/main.svg
|
|
233
328
|
[coverage-url]: https://codecov.io/github/stdlib-js/stats-base-dists-normal-mgf?branch=main
|
|
@@ -239,8 +334,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
239
334
|
|
|
240
335
|
-->
|
|
241
336
|
|
|
242
|
-
[chat-image]: https://img.shields.io/
|
|
243
|
-
[chat-url]: https://
|
|
337
|
+
[chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
|
|
338
|
+
[chat-url]: https://stdlib.zulipchat.com
|
|
244
339
|
|
|
245
340
|
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
246
341
|
|
|
@@ -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_NORMAL_MGF_H
|
|
20
|
+
#define STDLIB_STATS_BASE_DISTS_NORMAL_MGF_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
|
+
* Evaluates the moment-generating function (MGF) for a normal distribution with parameters `mu` (mean) and `sigma` (standard deviation).
|
|
31
|
+
*/
|
|
32
|
+
double stdlib_base_dists_normal_mgf( const double t, const double mu, const double sigma );
|
|
33
|
+
|
|
34
|
+
#ifdef __cplusplus
|
|
35
|
+
}
|
|
36
|
+
#endif
|
|
37
|
+
|
|
38
|
+
#endif // !STDLIB_STATS_BASE_DISTS_NORMAL_MGF_H
|
package/lib/native.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
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
|
+
* Evaluates the moment-generating function (MGF) for a normal distribution with mean `mu` and standard deviation `sigma` at a value `t`.
|
|
30
|
+
*
|
|
31
|
+
* @private
|
|
32
|
+
* @param {number} t - input value
|
|
33
|
+
* @param {number} mu - mean
|
|
34
|
+
* @param {PositiveNumber} sigma - standard deviation
|
|
35
|
+
* @returns {number} evaluated MGF
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* var y = mgf( 2.0, 0.0, 1.0 );
|
|
39
|
+
* // returns ~7.389
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* var y = mgf( 0.0, 0.0, 1.0 );
|
|
43
|
+
* // returns 1.0
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* var y = mgf( -1.0, 4.0, 2.0 );
|
|
47
|
+
* // returns ~0.1353
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* var y = mgf( NaN, 0.0, 1.0 );
|
|
51
|
+
* // returns NaN
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* var y = mgf( 0.0, NaN, 1.0 );
|
|
55
|
+
* // returns NaN
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* var y = mgf( 0.0, 0.0, NaN );
|
|
59
|
+
* // returns NaN
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* var y = mgf( 2.0, 0.0, 0.0 );
|
|
63
|
+
* // returns NaN
|
|
64
|
+
*/
|
|
65
|
+
function mgf( t, mu, sigma ) {
|
|
66
|
+
return addon( t, mu, sigma );
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
// EXPORTS //
|
|
71
|
+
|
|
72
|
+
module.exports = mgf;
|
package/manifest.json
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
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-ternary",
|
|
42
|
+
"@stdlib/math-base-assert-is-nan",
|
|
43
|
+
"@stdlib/math-base-special-pow",
|
|
44
|
+
"@stdlib/math-base-special-exp"
|
|
45
|
+
]
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"task": "benchmark",
|
|
49
|
+
"wasm": false,
|
|
50
|
+
"src": [
|
|
51
|
+
"./src/main.c"
|
|
52
|
+
],
|
|
53
|
+
"include": [
|
|
54
|
+
"./include"
|
|
55
|
+
],
|
|
56
|
+
"libraries": [],
|
|
57
|
+
"libpath": [],
|
|
58
|
+
"dependencies": [
|
|
59
|
+
"@stdlib/math-base-assert-is-nan",
|
|
60
|
+
"@stdlib/math-base-special-pow",
|
|
61
|
+
"@stdlib/math-base-special-exp",
|
|
62
|
+
"@stdlib/constants-float64-eps"
|
|
63
|
+
]
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"task": "examples",
|
|
67
|
+
"wasm": false,
|
|
68
|
+
"src": [
|
|
69
|
+
"./src/main.c"
|
|
70
|
+
],
|
|
71
|
+
"include": [
|
|
72
|
+
"./include"
|
|
73
|
+
],
|
|
74
|
+
"libraries": [],
|
|
75
|
+
"libpath": [],
|
|
76
|
+
"dependencies": [
|
|
77
|
+
"@stdlib/math-base-assert-is-nan",
|
|
78
|
+
"@stdlib/math-base-special-pow",
|
|
79
|
+
"@stdlib/math-base-special-exp",
|
|
80
|
+
"@stdlib/constants-float64-eps"
|
|
81
|
+
]
|
|
82
|
+
}
|
|
83
|
+
]
|
|
84
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stdlib/stats-base-dists-normal-mgf",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Normal distribution moment-generating function (MGF).",
|
|
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",
|
|
@@ -30,11 +33,13 @@
|
|
|
30
33
|
"url": "https://github.com/stdlib-js/stdlib/issues"
|
|
31
34
|
},
|
|
32
35
|
"dependencies": {
|
|
33
|
-
"@stdlib/math-base-assert-is-nan": "^0.2.
|
|
34
|
-
"@stdlib/math-base-
|
|
35
|
-
"@stdlib/math-base-special-
|
|
36
|
-
"@stdlib/
|
|
37
|
-
"@stdlib/utils-
|
|
36
|
+
"@stdlib/math-base-assert-is-nan": "^0.2.2",
|
|
37
|
+
"@stdlib/math-base-napi-ternary": "^0.3.1",
|
|
38
|
+
"@stdlib/math-base-special-exp": "^0.2.4",
|
|
39
|
+
"@stdlib/math-base-special-pow": "^0.3.0",
|
|
40
|
+
"@stdlib/utils-constant-function": "^0.2.2",
|
|
41
|
+
"@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2",
|
|
42
|
+
"@stdlib/utils-library-manifest": "^0.2.3"
|
|
38
43
|
},
|
|
39
44
|
"devDependencies": {},
|
|
40
45
|
"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/normal/mgf.h"
|
|
20
|
+
#include "stdlib/math/base/napi/ternary.h"
|
|
21
|
+
|
|
22
|
+
STDLIB_MATH_BASE_NAPI_MODULE_DDD_D( stdlib_base_dists_normal_mgf )
|
package/src/main.c
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
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/normal/mgf.h"
|
|
20
|
+
#include "stdlib/math/base/assert/is_nan.h"
|
|
21
|
+
#include "stdlib/math/base/special/pow.h"
|
|
22
|
+
#include "stdlib/math/base/special/exp.h"
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Evaluates the moment-generating function (MGF) for a normal distribution with mean `mu` and standard deviation `sigma` at a value `t`.
|
|
26
|
+
*
|
|
27
|
+
* @param t input value
|
|
28
|
+
* @param mu mean
|
|
29
|
+
* @param sigma standard deviation
|
|
30
|
+
* @return evaluated MGF
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* double y = stdlib_base_dists_normal_mgf( 2.0, 0.0, 1.0 );
|
|
34
|
+
* // returns ~7.389
|
|
35
|
+
*/
|
|
36
|
+
double stdlib_base_dists_normal_mgf( const double t, const double mu, const double sigma ) {
|
|
37
|
+
if (
|
|
38
|
+
stdlib_base_is_nan( t ) ||
|
|
39
|
+
stdlib_base_is_nan( mu ) ||
|
|
40
|
+
stdlib_base_is_nan( sigma ) ||
|
|
41
|
+
sigma <= 0.0
|
|
42
|
+
) {
|
|
43
|
+
return 0.0/0.0; // NaN
|
|
44
|
+
}
|
|
45
|
+
return stdlib_base_exp( ( mu*t ) + ( 0.5 * stdlib_base_pow( sigma*t, 2.0 ) ) );
|
|
46
|
+
}
|