time-to-botec

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

repl.txt (4037B)


      1 
      2 {{alias}}( N, correction, x, stride )
      3     Computes the variance of a strided array ignoring `NaN` values.
      4 
      5     The `N` and `stride` parameters determine which elements in `x` are accessed
      6     at runtime.
      7 
      8     Indexing is relative to the first index. To introduce an offset, use a typed
      9     array view.
     10 
     11     If `N <= 0`, the function returns `NaN`.
     12 
     13     If every indexed element is `NaN`, the function returns `NaN`.
     14 
     15     Parameters
     16     ----------
     17     N: integer
     18         Number of indexed elements.
     19 
     20     correction: number
     21         Degrees of freedom adjustment. Setting this parameter to a value other
     22         than `0` has the effect of adjusting the divisor during the calculation
     23         of the variance according to `n - c` where `c` corresponds to the
     24         provided degrees of freedom adjustment and `n` corresponds to the number
     25         of non-`NaN` indexed elements. When computing the variance of a
     26         population, setting this parameter to `0` is the standard choice (i.e.,
     27         the provided array contains data constituting an entire population).
     28         When computing the unbiased sample variance, setting this parameter to
     29         `1` is the standard choice (i.e., the provided array contains data
     30         sampled from a larger population; this is commonly referred to as
     31         Bessel's correction).
     32 
     33     x: Array<number>|TypedArray
     34         Input array.
     35 
     36     stride: integer
     37         Index increment.
     38 
     39     Returns
     40     -------
     41     out: number
     42         The variance.
     43 
     44     Examples
     45     --------
     46     // Standard Usage:
     47     > var x = [ 1.0, -2.0, NaN, 2.0 ];
     48     > {{alias}}( x.length, 1, x, 1 )
     49     ~4.3333
     50 
     51     // Using `N` and `stride` parameters:
     52     > x = [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0 ];
     53     > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 );
     54     > var stride = 2;
     55     > {{alias}}( N, 1, x, stride )
     56     ~4.3333
     57 
     58     // Using view offsets:
     59     > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ] );
     60     > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 );
     61     > N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 );
     62     > stride = 2;
     63     > {{alias}}( N, 1, x1, stride )
     64     ~4.3333
     65 
     66 {{alias}}.ndarray( N, correction, x, stride, offset )
     67     Computes the variance of a strided array ignoring `NaN` values and using
     68     alternative indexing semantics.
     69 
     70     While typed array views mandate a view offset based on the underlying
     71     buffer, the `offset` parameter supports indexing semantics based on a
     72     starting index.
     73 
     74     Parameters
     75     ----------
     76     N: integer
     77         Number of indexed elements.
     78 
     79     correction: number
     80         Degrees of freedom adjustment. Setting this parameter to a value other
     81         than `0` has the effect of adjusting the divisor during the calculation
     82         of the variance according to `n - c` where `c` corresponds to the
     83         provided degrees of freedom adjustment and `n` corresponds to the number
     84         of non-`NaN` indexed elements. When computing the variance of a
     85         population, setting this parameter to `0` is the standard choice (i.e.,
     86         the provided array contains data constituting an entire population).
     87         When computing the unbiased sample variance, setting this parameter to
     88         `1` is the standard choice (i.e., the provided array contains data
     89         sampled from a larger population; this is commonly referred to as
     90         Bessel's correction).
     91 
     92     x: Array<number>|TypedArray
     93         Input array.
     94 
     95     stride: integer
     96         Index increment.
     97 
     98     offset: integer
     99         Starting index.
    100 
    101     Returns
    102     -------
    103     out: number
    104         The variance.
    105 
    106     Examples
    107     --------
    108     // Standard Usage:
    109     > var x = [ 1.0, -2.0, NaN, 2.0 ];
    110     > {{alias}}.ndarray( x.length, 1, x, 1, 0 )
    111     ~4.3333
    112 
    113     // Using offset parameter:
    114     > var x = [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ];
    115     > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 );
    116     > {{alias}}.ndarray( N, 1, x, 2, 1 )
    117     ~4.3333
    118 
    119     See Also
    120     --------
    121