time-to-botec

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

repl.txt (4361B)


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