@stdlib/simulate-iter-awln 0.0.5 → 0.0.6
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 +36 -2
- package/lib/main.js +9 -10
- package/package.json +1 -1
package/NOTICE
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Copyright (c) 2016-
|
|
1
|
+
Copyright (c) 2016-2022 The Stdlib Authors.
|
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ limitations under the License.
|
|
|
20
20
|
|
|
21
21
|
# iterawln
|
|
22
22
|
|
|
23
|
-
[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] [![dependencies][dependencies-image]][dependencies-url]
|
|
23
|
+
[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] <!-- [![dependencies][dependencies-image]][dependencies-url] -->
|
|
24
24
|
|
|
25
25
|
> Create an [iterator][mdn-iterator-protocol] which introduces additive white Laplacian noise (AWLN).
|
|
26
26
|
|
|
@@ -212,6 +212,21 @@ while ( true ) {
|
|
|
212
212
|
|
|
213
213
|
<!-- /.references -->
|
|
214
214
|
|
|
215
|
+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
|
|
216
|
+
|
|
217
|
+
<section class="related">
|
|
218
|
+
|
|
219
|
+
* * *
|
|
220
|
+
|
|
221
|
+
## See Also
|
|
222
|
+
|
|
223
|
+
- <span class="package-name">[`@stdlib/simulate/iter/awgn`][@stdlib/simulate/iter/awgn]</span><span class="delimiter">: </span><span class="description">create an iterator which introduces additive white Gaussian noise.</span>
|
|
224
|
+
- <span class="package-name">[`@stdlib/simulate/iter/awun`][@stdlib/simulate/iter/awun]</span><span class="delimiter">: </span><span class="description">create an iterator which introduces additive white uniform noise.</span>
|
|
225
|
+
|
|
226
|
+
</section>
|
|
227
|
+
|
|
228
|
+
<!-- /.related -->
|
|
229
|
+
|
|
215
230
|
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
|
216
231
|
|
|
217
232
|
|
|
@@ -238,7 +253,7 @@ See [LICENSE][stdlib-license].
|
|
|
238
253
|
|
|
239
254
|
## Copyright
|
|
240
255
|
|
|
241
|
-
Copyright © 2016-
|
|
256
|
+
Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors].
|
|
242
257
|
|
|
243
258
|
</section>
|
|
244
259
|
|
|
@@ -257,9 +272,20 @@ Copyright © 2016-2021. The Stdlib [Authors][stdlib-authors].
|
|
|
257
272
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/simulate-iter-awln/main.svg
|
|
258
273
|
[coverage-url]: https://codecov.io/github/stdlib-js/simulate-iter-awln?branch=main
|
|
259
274
|
|
|
275
|
+
<!--
|
|
276
|
+
|
|
260
277
|
[dependencies-image]: https://img.shields.io/david/stdlib-js/simulate-iter-awln.svg
|
|
261
278
|
[dependencies-url]: https://david-dm.org/stdlib-js/simulate-iter-awln/main
|
|
262
279
|
|
|
280
|
+
-->
|
|
281
|
+
|
|
282
|
+
[umd]: https://github.com/umdjs/umd
|
|
283
|
+
[es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
|
|
284
|
+
|
|
285
|
+
[deno-url]: https://github.com/stdlib-js/simulate-iter-awln/tree/deno
|
|
286
|
+
[umd-url]: https://github.com/stdlib-js/simulate-iter-awln/tree/umd
|
|
287
|
+
[esm-url]: https://github.com/stdlib-js/simulate-iter-awln/tree/esm
|
|
288
|
+
|
|
263
289
|
[chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
|
|
264
290
|
[chat-url]: https://gitter.im/stdlib-js/stdlib/
|
|
265
291
|
|
|
@@ -275,6 +301,14 @@ Copyright © 2016-2021. The Stdlib [Authors][stdlib-authors].
|
|
|
275
301
|
|
|
276
302
|
[@stdlib/random/base/mt19937]: https://www.npmjs.com/package/@stdlib/random-base-mt19937
|
|
277
303
|
|
|
304
|
+
<!-- <related-links> -->
|
|
305
|
+
|
|
306
|
+
[@stdlib/simulate/iter/awgn]: https://www.npmjs.com/package/@stdlib/simulate-iter-awgn
|
|
307
|
+
|
|
308
|
+
[@stdlib/simulate/iter/awun]: https://www.npmjs.com/package/@stdlib/simulate-iter-awun
|
|
309
|
+
|
|
310
|
+
<!-- </related-links> -->
|
|
311
|
+
|
|
278
312
|
</section>
|
|
279
313
|
|
|
280
314
|
<!-- /.links -->
|
package/lib/main.js
CHANGED
|
@@ -240,27 +240,26 @@ function iterawln( iterator, sigma, options ) {
|
|
|
240
240
|
* @returns {Object} iterator protocol-compliant object
|
|
241
241
|
*/
|
|
242
242
|
function next() {
|
|
243
|
-
var out;
|
|
244
243
|
var v;
|
|
245
244
|
if ( FLG ) {
|
|
246
245
|
return {
|
|
247
246
|
'done': true
|
|
248
247
|
};
|
|
249
248
|
}
|
|
250
|
-
out = {};
|
|
251
249
|
v = iterator.next();
|
|
252
|
-
if ( typeof v.value === 'number' ) {
|
|
253
|
-
out.value = v.value + rlaplace();
|
|
254
|
-
} else if ( hasOwnProp( v, 'value' ) ) {
|
|
255
|
-
out.value = NaN;
|
|
256
|
-
}
|
|
257
250
|
if ( v.done ) {
|
|
258
251
|
FLG = true;
|
|
259
|
-
|
|
252
|
+
return v;
|
|
253
|
+
}
|
|
254
|
+
if ( typeof v.value === 'number' ) {
|
|
255
|
+
v = v.value + rlaplace();
|
|
260
256
|
} else {
|
|
261
|
-
|
|
257
|
+
v = NaN;
|
|
262
258
|
}
|
|
263
|
-
return
|
|
259
|
+
return {
|
|
260
|
+
'value': v,
|
|
261
|
+
'done': false
|
|
262
|
+
};
|
|
264
263
|
}
|
|
265
264
|
|
|
266
265
|
/**
|