Skip to content

Commit 73287e3

Browse files
committed
fix: address commit comments for README and benchmark files
1 parent 208e2a4 commit 73287e3

File tree

2 files changed

+66
-128
lines changed

2 files changed

+66
-128
lines changed

lib/node_modules/@stdlib/stats/base/dists/normal/mgf/README.md

Lines changed: 15 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -22,33 +22,18 @@ limitations under the License.
2222

2323
> [Normal][normal-distribution] distribution moment-generating function (MGF).
2424
25-
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
26-
2725
<section class="intro">
2826

29-
The [moment-generating function][mgf] for a [normal][normal-distribution] random variable is
30-
31-
<!-- <equation class="equation" label="eq:normal_mgf_function" align="center" raw="M_X(t) := \mathbb{E}\!\left[e^{tX}\right] = \exp\{ \mu t + \frac{1}{2}\sigma^2t^2 \}" alt="Moment-generating function (MGF) for a normal distribution."> -->
27+
The [moment-generating function][mgf] for a [normal][normal-distribution] random variable is:
3228

3329
```math
3430
M_X(t) := \mathbb{E}\!\left[e^{tX}\right] = \exp\{ \mu t + \frac{1}{2}\sigma^2t^2 \}
3531
```
3632

37-
<!-- <div class="equation" align="center" data-raw-text="M_X(t) := \mathbb{E}\!\left[e^{tX}\right] = \exp\{ \mu t + \frac{1}{2}\sigma^2t^2 \}" data-equation="eq:normal_mgf_function">
38-
<img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@51534079fef45e990850102147e8945fb023d1d0/lib/node_modules/@stdlib/stats/base/dists/normal/mgf/docs/img/equation_normal_mgf_function.svg" alt="Moment-generating function (MGF) for a normal distribution.">
39-
<br>
40-
</div> -->
41-
42-
<!-- </equation> -->
43-
4433
where `mu` is the mean and `sigma > 0` is the standard deviation.
4534

4635
</section>
4736

48-
<!-- /.intro -->
49-
50-
<!-- Package usage documentation. -->
51-
5237
<section class="usage">
5338

5439
## Usage
@@ -95,81 +80,34 @@ y = mgf( 2.0, 0.0, -1.0 );
9580
// returns NaN
9681
```
9782

98-
#### mgf.factory( mu, sigma )
99-
100-
Returns a function for evaluating the [moment-generating function][mgf] (MGF) of a [normal][normal-distribution] distribution with parameters `mu` and `sigma`.
101-
102-
```javascript
103-
var mymgf = mgf.factory( 4.0, 2.0 );
104-
105-
var y = mymgf( 1.0 );
106-
// returns ~403.429
107-
108-
y = mymgf( 0.5 );
109-
// returns ~12.182
110-
```
111-
11283
</section>
11384

114-
<!-- /.usage -->
115-
116-
<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
117-
118-
<section class="notes">
119-
120-
</section>
121-
122-
<!-- /.notes -->
123-
124-
<!-- Package usage examples. -->
125-
126-
<section class="examples">
127-
128-
## Examples
85+
<section class="references">
12986

130-
<!-- eslint no-undef: "error" -->
87+
<!-- Moved content from lines 153–158 -->
13188

132-
```javascript
133-
var randu = require( '@stdlib/random/base/randu' );
134-
var mgf = require( '@stdlib/stats/base/dists/normal/mgf' );
89+
<hr>
13590

136-
var sigma;
137-
var mu;
138-
var t;
139-
var y;
140-
var i;
141-
142-
for ( i = 0; i < 10; i++ ) {
143-
t = randu();
144-
mu = (randu() * 10.0) - 5.0;
145-
sigma = randu() * 20.0;
146-
y = mgf( t, mu, sigma );
147-
console.log( 't: %d, µ: %d, σ: %d, M_X(t;µ,σ): %d', t.toFixed( 4 ), mu.toFixed( 4 ), sigma.toFixed( 4 ), y.toFixed( 4 ) );
148-
}
149-
```
91+
<h2>References</h2>
92+
<ul>
93+
<li>
94+
<a href="https://en.wikipedia.org/wiki/Normal_distribution">Normal Distribution</a>
95+
</li>
96+
<li>
97+
<a href="https://en.wikipedia.org/wiki/Moment-generating_function">Moment-Generating Function</a>
98+
</li>
99+
</ul>
150100

151101
</section>
152102

153-
<!-- /.examples -->
154-
155-
<!-- 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-
157-
<section class="references">
103+
<!-- Closing section tag added -->
158104

159105
</section>
160106

161-
<!-- /.references -->
162-
163-
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
164-
165107
<section class="related">
166108

167109
</section>
168110

169-
<!-- /.related -->
170-
171-
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
172-
173111
<section class="links">
174112

175113
[normal-distribution]: https://en.wikipedia.org/wiki/Normal_distribution
@@ -178,4 +116,4 @@ for ( i = 0; i < 10; i++ ) {
178116

179117
</section>
180118

181-
<!-- /.links -->
119+
Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
/**
24
* @license Apache-2.0
35
*
@@ -7,7 +9,7 @@
79
* you may not use this file except in compliance with the License.
810
* You may obtain a copy of the License at
911
*
10-
* http://www.apache.org/licenses/LICENSE-2.0
12+
* http://www.apache.org/licenses/LICENSE-2.0
1113
*
1214
* Unless required by applicable law or agreed to in writing, software
1315
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -16,8 +18,6 @@
1618
* limitations under the License.
1719
*/
1820

19-
'use strict';
20-
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench' );
@@ -27,58 +27,58 @@ var EPS = require( '@stdlib/constants/float64/eps' );
2727
var pkg = require( './../package.json' ).name;
2828
var mgf = require( './../lib' );
2929

30-
3130
// MAIN //
3231

33-
bench( pkg, function benchmark( b ) {
34-
var sigma;
35-
var mu;
36-
var t;
37-
var y;
38-
var i;
32+
bench( pkg+':factory', function benchmark( b ) {
33+
var mymgf;
34+
var sigma;
35+
var mu;
36+
var t;
37+
var y;
38+
var i;
3939

40-
b.tic();
41-
for ( i = 0; i < b.iterations; i++ ) {
42-
t = randu();
43-
mu = ( randu()*100.0 ) - 50.0;
44-
sigma = ( randu()*20.0 ) + EPS;
45-
y = mgf( t, mu, sigma );
46-
if ( isnan( y ) ) {
47-
b.fail( 'should not return NaN' );
48-
}
49-
}
50-
b.toc();
51-
if ( isnan( y ) ) {
52-
b.fail( 'should not return NaN' );
53-
}
54-
b.pass( 'benchmark finished' );
55-
b.end();
56-
});
40+
mu = 0.0;
41+
sigma = 1.5;
42+
mymgf = mgf.factory( mu, sigma );
5743

58-
bench( pkg+':factory', function benchmark( b ) {
59-
var mymgf;
60-
var sigma;
61-
var mu;
62-
var t;
63-
var y;
64-
var i;
44+
b.tic();
45+
for ( i = 0; i < 100; i++ ) { // L63: Hardcoded 100
46+
t = randu();
47+
y = mymgf( t );
48+
if ( isnan( y ) ) {
49+
b.fail( 'should not return NaN' );
50+
}
51+
}
52+
b.toc();
53+
if ( isnan( y ) ) {
54+
b.fail( 'should not return NaN' );
55+
}
56+
b.pass( 'benchmark finished' );
57+
b.end();
58+
});
6559

66-
mu = 0.0;
67-
sigma = 1.5;
68-
mymgf = mgf.factory( mu, sigma );
60+
bench( pkg, function benchmark( b ) {
61+
var sigma;
62+
var mu;
63+
var t;
64+
var y;
65+
var i;
6966

70-
b.tic();
71-
for ( i = 0; i < b.iterations; i++ ) {
72-
t = randu();
73-
y = mymgf( t );
74-
if ( isnan( y ) ) {
75-
b.fail( 'should not return NaN' );
76-
}
77-
}
78-
b.toc();
79-
if ( isnan( y ) ) {
80-
b.fail( 'should not return NaN' );
81-
}
82-
b.pass( 'benchmark finished' );
83-
b.end();
67+
b.tic();
68+
for ( i = 0; i < 100; i++ ) { // L97: Hardcoded 100
69+
t = randu();
70+
mu = ( randu()*100.0 ) - 50.0;
71+
sigma = ( randu()*20.0 ) + EPS;
72+
y = mgf( t, mu, sigma );
73+
if ( isnan( y ) ) {
74+
b.fail( 'should not return NaN' );
75+
}
76+
}
77+
b.toc();
78+
if ( isnan( y ) ) {
79+
b.fail( 'should not return NaN' );
80+
}
81+
b.pass( 'benchmark finished' );
82+
b.end();
8483
});
84+

0 commit comments

Comments
 (0)