time-to-botec

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

repl.txt (3624B)


      1 
      2 {{alias}}( x, sigma[, options] )
      3     Computes a one-sample z-test.
      4 
      5     The function performs a one-sample z-test for the null hypothesis that the
      6     data in array or typed array `x` is drawn from a normal distribution with
      7     mean zero and standard deviation `sigma`.
      8 
      9     The returned object comes with a `.print()` method which when invoked will
     10     print a formatted output of the results of the hypothesis test.
     11 
     12     Parameters
     13     ----------
     14     x: Array<number>
     15         Data array.
     16 
     17     sigma: number
     18         Known standard deviation.
     19 
     20     options: Object (optional)
     21         Options.
     22 
     23     options.alpha: number (optional)
     24         Number in the interval `[0,1]` giving the significance level of the
     25         hypothesis test. Default: `0.05`.
     26 
     27     options.alternative: string (optional)
     28         Indicates whether the alternative hypothesis is that the mean of `x` is
     29         larger than `mu` (`greater`), smaller than `mu` (`less`) or equal to
     30         `mu` (`two-sided`). Default: `'two-sided'`.
     31 
     32     options.mu: number (optional)
     33         Hypothesized true mean under the null hypothesis. Set this option to
     34         test whether the data comes from a distribution with the specified `mu`.
     35         Default: `0`.
     36 
     37     Returns
     38     -------
     39     out: Object
     40         Test result object.
     41 
     42     out.alpha: number
     43         Used significance level.
     44 
     45     out.rejected: boolean
     46         Test decision.
     47 
     48     out.pValue: number
     49         p-value of the test.
     50 
     51     out.statistic: number
     52         Value of test statistic.
     53 
     54     out.ci: Array<number>
     55         1-alpha confidence interval for mean.
     56 
     57     out.nullValue: number
     58         Assumed mean value under H0.
     59 
     60     out.sd: number
     61         Standard error.
     62 
     63     out.alternative: string
     64         Alternative hypothesis (`two-sided`, `less` or `greater`).
     65 
     66     out.method: string
     67         Name of test (`One-Sample z-test`).
     68 
     69     out.print: Function
     70         Function to print formatted output.
     71 
     72     Examples
     73     --------
     74     // One-sample z-test:
     75     > var rnorm = {{alias:@stdlib/random/base/normal}}.factory( 0.0, 2.0, { 'seed': 212 });
     76     > var x = new Array( 100 );
     77     > for ( var i = 0; i < x.length; i++ ) {
     78     ...     x[ i ] = rnorm();
     79     ... }
     80     > var out = {{alias}}( x, 2.0 )
     81     {
     82         alpha: 0.05,
     83         rejected: false,
     84         pValue: ~0.180,
     85         statistic: ~-1.34,
     86         ci: [ ~-0.66, ~0.124 ],
     87         ...
     88     }
     89 
     90     // Choose custom significance level and print output:
     91     > arr = [ 2, 4, 3, 1, 0 ];
     92     > out = {{alias}}( arr, 2.0, { 'alpha': 0.01 });
     93     > table = out.print()
     94     One-sample z-test
     95 
     96     Alternative hypothesis: True mean is not equal to 0
     97 
     98         pValue: 0.0253
     99         statistic: 2.2361
    100         99% confidence interval: [-0.3039,4.3039]
    101 
    102     Test Decision: Fail to reject null in favor of alternative at 1%
    103     significance level
    104 
    105 
    106     // Test for a mean equal to five:
    107     > var arr = [ 4, 4, 6, 6, 5 ];
    108     > out = {{alias}}( arr, 1.0, { 'mu': 5 })
    109     {
    110         rejected: false,
    111         pValue: 1,
    112         statistic: 0,
    113         ci: [ ~4.123, ~5.877 ],
    114         // ...
    115     }
    116 
    117     // Perform one-sided tests:
    118     > arr = [ 4, 4, 6, 6, 5 ];
    119     > out = {{alias}}( arr, 1.0, { 'alternative': 'less' })
    120     {
    121         alpha: 0.05,
    122         rejected: false,
    123         pValue: 1,
    124         statistic: 11.180339887498949,
    125         ci: [ -Infinity, 5.735600904580115 ],
    126         // ...
    127     }
    128     > out = {{alias}}( arr, 1.0, { 'alternative': 'greater' })
    129     {
    130         alpha: 0.05,
    131         rejected: true,
    132         pValue: 0,
    133         statistic: 11.180339887498949,
    134         ci: [ 4.264399095419885, Infinity ],
    135         //...
    136     }
    137 
    138     See Also
    139     --------
    140