time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

README.md (3822B)


      1 <!--
      2 
      3 @license Apache-2.0
      4 
      5 Copyright (c) 2019 The Stdlib Authors.
      6 
      7 Licensed under the Apache License, Version 2.0 (the "License");
      8 you may not use this file except in compliance with the License.
      9 You may obtain a copy of the License at
     10 
     11    http://www.apache.org/licenses/LICENSE-2.0
     12 
     13 Unless required by applicable law or agreed to in writing, software
     14 distributed under the License is distributed on an "AS IS" BASIS,
     15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     16 See the License for the specific language governing permissions and
     17 limitations under the License.
     18 
     19 -->
     20 
     21 # itermeanabs2
     22 
     23 > Compute the [arithmetic mean][arithmetic-mean] of squared absolute values for all [iterated][mdn-iterator-protocol] values.
     24 
     25 <section class="intro">
     26 
     27 The [arithmetic mean][arithmetic-mean] of squared absolute values is defined as
     28 
     29 <!-- <equation class="equation" label="eq:arithmetic_mean_squared_absolute_values" align="center" raw="m = \frac{1}{n} \sum_{i=0}^{n-1} x_i^2" alt="Equation for the arithmetic mean of squared absolute values."> -->
     30 
     31 <div class="equation" align="center" data-raw-text="m = \frac{1}{n} \sum_{i=0}^{n-1} x_i^2" data-equation="eq:arithmetic_mean_squared_absolute_values">
     32     <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@d6537e6e0eb08987edeffda2d81b9a9197bdd7e0/lib/node_modules/@stdlib/stats/iter/meanabs2/docs/img/equation_arithmetic_mean_squared_absolute_values.svg" alt="Equation for the arithmetic mean of squared absolute values.">
     33     <br>
     34 </div>
     35 
     36 <!-- </equation> -->
     37 
     38 </section>
     39 
     40 <!-- /.intro -->
     41 
     42 <!-- Package usage documentation. -->
     43 
     44 <section class="usage">
     45 
     46 ## Usage
     47 
     48 ```javascript
     49 var itermeanabs2 = require( '@stdlib/stats/iter/meanabs2' );
     50 ```
     51 
     52 #### itermeanabs2( iterator )
     53 
     54 Computes the [arithmetic mean][arithmetic-mean] of squared absolute values for all [iterated][mdn-iterator-protocol] values.
     55 
     56 ```javascript
     57 var array2iterator = require( '@stdlib/array/to-iterator' );
     58 
     59 var arr = array2iterator( [ 1.0, -2.0, -3.0, 4.0 ] );
     60 
     61 var m = itermeanabs2( arr );
     62 // returns 7.5
     63 ```
     64 
     65 </section>
     66 
     67 <!-- /.usage -->
     68 
     69 <!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
     70 
     71 <section class="notes">
     72 
     73 ## Notes
     74 
     75 -   If an iterated value is non-numeric (including `NaN`), the returned [`iterator`][mdn-iterator-protocol] returns `NaN`. If non-numeric iterated values are possible, you are advised to provide an [`iterator`][mdn-iterator-protocol] which type checks and handles non-numeric values accordingly.
     76 
     77 </section>
     78 
     79 <!-- /.notes -->
     80 
     81 <!-- Package usage examples. -->
     82 
     83 <section class="examples">
     84 
     85 ## Examples
     86 
     87 <!-- eslint no-undef: "error" -->
     88 
     89 ```javascript
     90 var runif = require( '@stdlib/random/iter/uniform' );
     91 var itermeanabs2 = require( '@stdlib/stats/iter/meanabs2' );
     92 
     93 // Create an iterator for generating uniformly distributed pseudorandom numbers:
     94 var rand = runif( -10.0, 10.0, {
     95     'seed': 1234,
     96     'iter': 100
     97 });
     98 
     99 // Compute the arithmetic mean of squared absolute values:
    100 var m = itermeanabs2( rand );
    101 // returns <number>
    102 
    103 console.log( 'meanabs2: %d.', m );
    104 ```
    105 
    106 </section>
    107 
    108 <!-- /.examples -->
    109 
    110 <!-- 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. -->
    111 
    112 <section class="references">
    113 
    114 </section>
    115 
    116 <!-- /.references -->
    117 
    118 <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
    119 
    120 <section class="links">
    121 
    122 [arithmetic-mean]: https://en.wikipedia.org/wiki/Arithmetic_mean
    123 
    124 [mdn-iterator-protocol]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterator_protocol
    125 
    126 </section>
    127 
    128 <!-- /.links -->