time-to-botec

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

README.md (4585B)


      1 <!--
      2 
      3 @license Apache-2.0
      4 
      5 Copyright (c) 2021 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 # Levene's Test
     22 
     23 > Compute Levene's test for equal variances.
     24 
     25 <section class="intro">
     26 
     27 Levene's test is used to test the null hypothesis that the variances of `k` groups are equal against the alternative that at least two of them are different.
     28 
     29 </section>
     30 
     31 <!-- /.intro -->
     32 
     33 <section class="usage">
     34 
     35 ## Usage
     36 
     37 ```javascript
     38 var leveneTest = require( '@stdlib/stats/levene-test' );
     39 ```
     40 
     41 #### leveneTest( x\[, y, ..., z]\[, opts] )
     42 
     43 Calculates Levene's test for input arrays `x`, `y`, ..., `z` holding numeric observations. 
     44 
     45 ```javascript
     46 // Data from Hollander & Wolfe (1973), p. 116:
     47 var x = [ 2.9, 3.0, 2.5, 2.6, 3.2 ];
     48 var y = [ 3.8, 2.7, 4.0, 2.4 ];
     49 var z = [ 2.8, 3.4, 3.7, 2.2, 2.0 ];
     50 
     51 var out = leveneTest( x, y, z );
     52 /* returns
     53     {
     54         'rejected': false,
     55         'alpha': 0.05,
     56         'df': [ 2, 11 ],
     57         'pValue': ~0.1733,
     58         'statistic': ~2.0638,
     59         ...
     60     }
     61 */
     62 ```
     63 
     64 The function accepts the following `options`:
     65 
     66 -   **alpha**: `number` on the interval `[0,1]` giving the significance level of the hypothesis test. Default: `0.05`.
     67 -   **groups**: an `array` of group indicators. Only applicable when providing a single numeric array holding all observations.
     68 
     69 By default, the test is carried out at a significance level of `0.05`. To test at a different significance level, set the `alpha` option.
     70 
     71 ```javascript
     72 var x = [ 2.9, 3.0, 2.5, 2.6, 3.2 ];
     73 var y = [ 3.8, 2.7, 4.0, 2.4 ];
     74 var z = [ 2.8, 3.4, 3.7, 2.2, 2.0 ];
     75 
     76 var out = leveneTest( x, y, z, {
     77     'alpha': 0.01
     78 });
     79 /* returns
     80     {
     81         'rejected': false,
     82         'alpha': 0.01,
     83         'df': [ 2, 11 ],
     84         'pValue': ~0.1733,
     85         'statistic': ~2.0638,
     86         ...
     87     }
     88 */
     89 ```
     90 
     91 In addition to providing multiple arrays, the function supports providing a single numeric array holding all observations along with an array of group indicators.
     92 
     93 <!-- eslint-disable array-element-newline -->
     94 
     95 ```javascript
     96 var arr = [
     97     2.9, 3.0, 2.5, 2.6, 3.2,
     98     3.8, 2.7, 4.0, 2.4,
     99     2.8, 3.4, 3.7, 2.2, 2.0
    100 ];
    101 var groups = [
    102     'a', 'a', 'a', 'a', 'a',
    103     'b', 'b', 'b', 'b',
    104     'c', 'c', 'c', 'c', 'c'
    105 ];
    106 var out = leveneTest( arr, {
    107     'groups': groups
    108 });
    109 ```
    110 
    111 The returned object comes with a `.print()` method which, when invoked, prints a formatted output of test results. The method accepts the following options:
    112 
    113 -   **digits**: number of decimal digits displayed for the outputs. Default: `4`.
    114 -   **decision**: `boolean` indicating whether to print the test decision. Default: `true`.
    115 
    116 ```javascript
    117 var x = [ 2.9, 3.0, 2.5, 2.6, 3.2 ];
    118 var y = [ 3.8, 2.7, 4.0, 2.4 ];
    119 var z = [ 2.8, 3.4, 3.7, 2.2, 2.0 ];
    120 
    121 var out = leveneTest( x, y, z );
    122 console.log( out.print() );
    123 /* =>
    124     Levene's test for Homogeneity of Variance
    125 
    126     Null hypothesis: The variances in all groups are the same.
    127 
    128         df 1: 2
    129         df 2: 11
    130         F score: 2.0638
    131         P Value: 0.1733
    132 
    133     Test Decision: Fail to reject null in favor of alternative at 5% significance level
    134 */
    135 ```
    136 
    137 </section>
    138 
    139 <!-- /.usage -->
    140 
    141 <section class="examples">
    142 
    143 ## Examples
    144 
    145 <!-- eslint no-undef: "error" -->
    146 
    147 ```javascript
    148 var leveneTest = require( '@stdlib/stats/levene-test' );
    149 
    150 // Data from Hollander & Wolfe (1973), p. 116:
    151 var x = [ 2.9, 3.0, 2.5, 2.6, 3.2 ];
    152 var y = [ 3.8, 2.7, 4.0, 2.4 ];
    153 var z = [ 2.8, 3.4, 3.7, 2.2, 2.0 ];
    154 
    155 var out = leveneTest( x, y, z );
    156 /* returns
    157     {
    158         'rejected': false,
    159         'alpha': 0.05,
    160         'df': [ 2, 11 ],
    161         'pValue': ~0.1733,
    162         'statistic': ~2.0638,
    163         ...
    164     }
    165 */
    166 
    167 var table = out.print();
    168 /* returns
    169     Levene's test for Homogeneity of Variance
    170 
    171     Null hypothesis: The variances in all groups are the same.
    172 
    173         df 1: 2
    174         df 2: 11
    175         F score: 2.0638
    176         P Value: 0.1733
    177 
    178     Test Decision: Fail to reject null in favor of alternative at 5% significance level
    179 */
    180 ```
    181 
    182 </section>
    183 
    184 <!-- /.examples -->
    185 
    186 <section class="references">
    187 
    188 </section>
    189 
    190 <!-- /.references -->
    191 
    192 <section class="links">
    193 
    194 </section>
    195 
    196 <!-- /.links -->