"ztest2": "\nztest2( x, y, sigmax, sigmay[, options] )\n Computes a two-sample z-test.\n\n By default, the function performs a two-sample z-test for the null\n hypothesis that the data in arrays or typed arrays `x` and `y` is\n independently drawn from normal distributions with equal means and known\n standard deviations `sigmax` and `sigmay`.\n\n The returned object comes with a `.print()` method which when invoked will\n print a formatted output of the results of the hypothesis test.\n\n Parameters\n ----------\n x: Array<number>\n First data array.\n\n y: Array<number>\n Second data array.\n\n sigmax: number\n Known standard deviation of first group.\n\n sigmay: number\n Known standard deviation of second group.\n\n options: Object (optional)\n Options.\n\n options.alpha: number (optional)\n Number in the interval `[0,1]` giving the significance level of the\n hypothesis test. Default: `0.05`.\n\n options.alternative: string (optional)\n Either `two-sided`, `less` or `greater`. Indicates whether the\n alternative hypothesis is that `x` has a larger mean than `y`\n (`greater`), `x` has a smaller mean than `y` (`less`) or the means are\n the same (`two-sided`). Default: `'two-sided'`.\n\n options.difference: number (optional)\n Number denoting the difference in means under the null hypothesis.\n Default: `0`.\n\n Returns\n -------\n out: Object\n Test result object.\n\n out.alpha: number\n Used significance level.\n\n out.rejected: boolean\n Test decision.\n\n out.pValue: number\n P-value of the test.\n\n out.statistic: number\n Value of test statistic.\n\n out.ci: Array<number>\n 1-alpha confidence interval for the mean.\n\n out.nullValue: number\n Assumed difference in means under H0.\n\n out.xmean: number\n Sample mean of `x`.\n\n out.ymean: number\n Sample mean of `y`.\n\n out.alternative: string\n Alternative hypothesis (`two-sided`, `less` or `greater`).\n\n out.method: string\n Name of test.\n\n out.print: function\n Function to print formatted output.\n\n Examples\n --------\n // Drawn from Normal(0,2):\n > var x = [ -0.21, 0.14, 1.65, 2.11, -1.86, -0.29, 1.48, 0.81, 0.86, 1.04 ];\n // Drawn from Normal(1,2):\n > var y = [ -1.53, -2.93, 2.34, -1.15, 2.7, -0.12, 4.22, 1.66, 3.43, 4.66 ];\n > var out = ztest2( x, y, 2.0, 2.0 )\n {\n alpha: 0.05,\n rejected: false,\n pValue: ~0.398,\n statistic: ~-0.844\n ci: [ ~-2.508, ~0.988 ],\n alternative: 'two-sided',\n method: 'Two-sample z-test',\n nullValue: 0,\n xmean: ~0.573,\n ymean: ~1.328\n }\n\n // Print table output:\n > var table = out.print();\n Two-sample z-test\n\n Alternative hypothesis: True difference in means is not equal to 0\n\n pValue: 0.3986\n statistic: -0.8441\n 95% confidence interval: [-2.508,0.998]\n\n Test Decision: Fail to reject null in favor of alternative at 5%\n significance level\n\n // Choose a different significance level than `0.05`:\n > out = ztest2( x, y, 2.0, 2.0, { 'alpha': 0.4 });\n > table = out.print();\n Two-sample z-test\n\n Alternative hypothesis: True difference in means is not equal to 0\n\n pValue: 0.3986\n statistic: -0.8441\n 60% confidence interval: [-1.5078,-0.0022]\n\n Test Decision: Reject null in favor of alternative at 40% significance level\n\n // Perform one-sided tests:\n > out = ztest2( x, y, 2.0, 2.0, { 'alternative': 'less' });\n > table = out.print()\n Two-sample z-test\n\n Alternative hypothesis: True difference in means is less than 0\n\n pValue: 0.1993\n statistic: -0.8441\n 95% confidence interval: [-Infinity,0.7162]\n\n Test Decision: Fail to reject null in favor of alternative at 5%\n significance level\n\n\n > out = ztest2( x, y, 2.0, 2.0, { 'alternative': 'greater' });\n > table = out.print()\n Two-sample z-test\n\n Alternative hypothesis: True difference in means is greater than 0\n\n pValue: 0.8007\n statistic: -0.8441\n 95% confidence interval: [-2.2262,Infinity]\n\n Test Decision: Fail to reject null in favor of alternative at 5%\n significance level\n\n // Test for a difference in means besides zero:\n > var rnorm = base.random.normal.factory({ 'seed': 372 });\n > x = new Array( 100 );\n > for ( i = 0; i < x.length; i++ ) {\n ... x[ i ] = rnorm( 2.0, 1.0 );\n ... }\n > y = new Array( 100 );\n ... for ( i = 0; i < x.length; i++ ) {\n ... y[ i ] = rnorm( 0.0, 2.0 );\n ... }\n > out = ztest2( x, y, 1.0, 2.0, { 'difference': 2.0 })\n {\n rejected: false,\n pValue: ~0.35,\n statistic: ~-0.935\n ci: [ ~1.353, ~2.229 ],\n // ...\n }\n\n See Also\n --------\n ztest\n"
0 commit comments