time-to-botec

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

repl.txt (3281B)


      1 
      2 {{alias}}( x, y[, options] )
      3     Computes a Pearson product-moment correlation test between paired samples.
      4 
      5     By default, the function performs a t-test for the null hypothesis that the
      6     data in arrays or typed arrays `x` and `y` is not correlated. A test against
      7     a different population correlation can be carried out by supplying the `rho`
      8     option. In this case, a test using the Fisher's z transform is conducted.
      9 
     10     The returned object comes with a `.print()` method which when invoked will
     11     print a formatted output of the results of the hypothesis test.
     12 
     13     Parameters
     14     ----------
     15     x: Array<number>
     16         First data array.
     17 
     18     y: Array<number>
     19         Second data array.
     20 
     21     options: Object (optional)
     22         Options.
     23 
     24     options.alpha: number (optional)
     25         Nnumber in the interval `[0,1]` giving the significance level of the
     26         hypothesis test. Default: `0.05`.
     27 
     28     options.alternative: string (optional)
     29         Either `two-sided`, `less` or `greater`. Indicates whether the
     30         alternative hypothesis is that `x` has a larger mean than `y`
     31         (`greater`), `x` has a smaller mean than `y` (`less`) or the means are
     32         the same (`two-sided`). Default: `'two-sided'`.
     33 
     34     options.rho: number (optional)
     35         Number denoting the correlation under the null hypothesis.
     36         Default: `0`.
     37 
     38     Returns
     39     -------
     40     out: Object
     41         Test result object.
     42 
     43     out.alpha: number
     44         Used significance level.
     45 
     46     out.rejected: boolean
     47         Test decision.
     48 
     49     out.pValue: number
     50         p-value of the test.
     51 
     52     out.statistic: number
     53         Value of test statistic.
     54 
     55     out.ci: Array<number>
     56         1-alpha confidence interval for the Pearson product-moment correlation
     57         coefficient. The confidence interval is calculated using Fisher's
     58         z-transform.
     59 
     60     out.nullValue: number
     61         Assumed correlation under H0 (equal to the supplied `rho` option).
     62 
     63     out.alternative: string
     64         Alternative hypothesis (`two-sided`, `less` or `greater`).
     65 
     66     out.method: string
     67         Name of test.
     68 
     69     out.print: Function
     70         Function to print formatted output.
     71 
     72     Examples
     73     --------
     74     > var rho = 0.5;
     75     > var x = new Array( 300 );
     76     > var y = new Array( 300 );
     77     > for ( var i = 0; i < 300; i++ ) {
     78     ...    x[ i ] = {{alias:@stdlib/random/base/normal}}( 0.0, 1.0 );
     79     ...    y[ i ] = ( rho * x[ i ] ) + {{alias:@stdlib/random/base/normal}}( 0.0,
     80     ...    {{alias:@stdlib/math/base/special/sqrt}}( 1.0 - (rho*rho) ) );
     81     ... }
     82     > var out = {{alias}}( x, y )
     83     {
     84         alpha: 0.05,
     85         rejected: true,
     86         pValue: 0,
     87         statistic: 10.115805615994121,
     88         ci: [ 0.4161679018930295, 0.5853122968949995 ],
     89         alternative: 'two-sided',
     90         method: 't-test for Pearson correlation coefficient',
     91         nullValue: 0,
     92         pcorr: 0.505582072355616,
     93     }
     94 
     95     // Print output:
     96     > var table = out.print()
     97     t-test for Pearson correlation coefficient
     98 
     99     Alternative hypothesis: True correlation coefficient is not equal to 0
    100 
    101         pValue: 0
    102         statistic: 9.2106
    103         95% confidence interval: [0.3776,0.5544]
    104 
    105     Test Decision: Reject null in favor of alternative at 5% significance level
    106 
    107     See Also
    108     --------
    109