time-to-botec

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

repl.txt (2651B)


      1 
      2 {{alias}}( N, x, stride )
      3     Computes the arithmetic mean of a single-precision floating-point strided
      4     array, ignoring `NaN` values and using Welford's algorithm.
      5 
      6     The `N` and `stride` parameters determine which elements in `x` are accessed
      7     at runtime.
      8 
      9     Indexing is relative to the first index. To introduce an offset, use a typed
     10     array view.
     11 
     12     If `N <= 0`, the function returns `NaN`.
     13 
     14     If every indexed element is `NaN`, the function returns `NaN`.
     15 
     16     Parameters
     17     ----------
     18     N: integer
     19         Number of indexed elements.
     20 
     21     x: Float32Array
     22         Input array.
     23 
     24     stride: integer
     25         Index increment.
     26 
     27     Returns
     28     -------
     29     out: float
     30         The arithmetic mean.
     31 
     32     Examples
     33     --------
     34     // Standard Usage:
     35     > var x = new {{alias:@stdlib/array/float32}}( [ 1.0, -2.0, NaN, 2.0 ] );
     36     > {{alias}}( x.length, x, 1 )
     37     ~0.3333
     38 
     39     // Using `N` and `stride` parameters:
     40     > x = new {{alias:@stdlib/array/float32}}( [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0, NaN ] );
     41     > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 );
     42     > var stride = 2;
     43     > {{alias}}( N, x, stride )
     44     ~0.3333
     45 
     46     // Using view offsets:
     47     > var x0 = new {{alias:@stdlib/array/float32}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0, NaN ] );
     48     > var x1 = new {{alias:@stdlib/array/float32}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 );
     49     > N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 );
     50     > stride = 2;
     51     > {{alias}}( N, x1, stride )
     52     ~-0.3333
     53 
     54 {{alias}}.ndarray( N, x, stride, offset )
     55     Computes the arithmetic mean of a single-precision floating-point strided
     56     array, ignoring `NaN` values and using Welford's algorithm and alternative
     57     indexing semantics.
     58 
     59     While typed array views mandate a view offset based on the underlying
     60     buffer, the `offset` parameter supports indexing semantics based on a
     61     starting index.
     62 
     63     Parameters
     64     ----------
     65     N: integer
     66         Number of indexed elements.
     67 
     68     x: Float32Array
     69         Input array.
     70 
     71     stride: integer
     72         Index increment.
     73 
     74     offset: integer
     75         Starting index.
     76 
     77     Returns
     78     -------
     79     out: float
     80         The arithmetic mean.
     81 
     82     Examples
     83     --------
     84     // Standard Usage:
     85     > var x = new {{alias:@stdlib/array/float32}}( [ 1.0, -2.0, NaN, 2.0 ] );
     86     > {{alias}}.ndarray( x.length, x, 1, 0 )
     87     ~0.3333
     88 
     89     // Using offset parameter:
     90     > var x = new {{alias:@stdlib/array/float32}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0, NaN ] );
     91     > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 );
     92     > {{alias}}.ndarray( N, x, 2, 1 )
     93     ~-0.3333
     94 
     95     See Also
     96     --------
     97