ZTEST function
PRO BASIC
The ZTEST function in Jspreadsheet Formulas Pro returns the one-tailed probability of a z-test: the chance that the sample mean would be at least as large as the observed mean if the population mean were x. It is used to test a hypothesis about a mean when the sample is large or the population standard deviation is known. It is the compatibility version of Z.TEST and returns the same values.
Documentation
Returns the one-tailed probability of a z-test.
Category
Statistical
Syntax
ZTEST(array, x, [sigma])
| Parameter | Description |
|---|---|
array |
The range or array of data to test against x. |
x |
The hypothesized population mean. |
[sigma] |
Optional. The known population standard deviation. When omitted, the sample standard deviation is used. |
Behavior
The ZTEST function returns 1 - NORM.S.DIST((AVERAGE(array) - x) / (sigma / SQRT(n)), TRUE), the upper-tail probability.
xis required in Jspreadsheet. Calling the function with onlyarrayreturns#N/A, unlike Excel, wherexis optional.- When
sigmais omitted the sample standard deviation is used.sigmamust be positive; 0 returns#NUM!. - The array needs at least two numeric values. A single value returns
#DIV/0!. - When the sample mean equals
xthe result is 0.5. - Text passed as
xor an array without numbers returns#VALUE!.
Common Errors
| Error | Description |
|---|---|
| #NUM! | Returned when sigma is less than or equal to 0. |
| #DIV/0! | Returned when array has fewer than two numeric values. |
| #VALUE! | Returned when x is text or when array contains no numbers. |
Best practices
- Always pass
x, since the function does not accept the one-argument form.- Make sure the array has at least two numeric values and no headers, since a single value returns
#DIV/0!and a range without numbers returns#VALUE!.- When providing
sigma, validate that it is positive, because 0 returns#NUM!.- Use absolute references for the array when the formula is copied to other cells.
Usage
A few examples using the ZTEST function.
// A2:A6 = 2, 4, 6, 8, 10
ZTEST(A2:A6, 3)
// Returns 0.016947
ZTEST(A2:A6, 3, 2)
// Returns 0.000398, using a known standard deviation of 2
ZTEST(A2:A6, 6)
// Returns 0.5, the sample mean equals x
ZTEST(A2:A6)
// Returns #N/A because x is required
Interactive Spreadsheet Demo
<html>
<script src="https://jsuites.net/v6/jsuites.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jspreadsheet@13/dist/index.min.js"></script>
<link rel="stylesheet" href="https://jsuites.net/v6/jsuites.css" type="text/css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jspreadsheet@13/dist/jspreadsheet.min.css" type="text/css" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Material+Icons" />
<script src="https://cdn.jsdelivr.net/npm/@jspreadsheet/formula-pro/dist/index.min.js"></script>
<div id="spreadsheet"></div>
<script>
// You can use the following license for quick testing on localhost, StackBlitz, or CodeSandbox.
// The license is valid for one day, after which the spreadsheet will become read-only.
// For a longer trial period, you can create a free account and generate a demo license with an extended expiration date.
jspreadsheet.setLicense('NGZmMGY0MjA5NGEwZGVhMmU5MTA5MmQ0ZDE2MGFmNDRhYzBhMjBjYzAxMGZjMjIwY2NkNDE5MzVhZDI0ODc5NzFlNTNlNzYyZWI2NzdjMWFlMTBmZDk0MWUzZGE4NDk4YTZhMzliMzgyMTdjNmMxMTZmMjYzNWU3NzgyY2MxOTMsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpreE9EY3dPRGt3TENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0p6ZEdGamEySnNhWFI2TG1sdklpd2lkMlZpWTI5dWRHRnBibVZ5TG1sdklpd2liRzlqWVd4b2IzTjBJbDBzSW5Cc1lXNGlPaUl6TkNJc0luTmpiM0JsSWpwYkluWTNJaXdpZGpnaUxDSjJPU0lzSW5ZeE1DSXNJbll4TVNJc0luWXhNaUlzSW5ZeE15SXNJbU5vWVhKMGN5SXNJbVp2Y20xeklpd2labTl5YlhWc1lTSXNJbkJoY25ObGNpSXNJbkpsYm1SbGNpSXNJbU52YlcxbGJuUnpJaXdpYVcxd2IzSjBaWElpTENKaVlYSWlMQ0oyWVd4cFpHRjBhVzl1Y3lJc0luTmxZWEpqYUNJc0luQnlhVzUwSWl3aWMyaGxaWFJ6SWl3aVkyeHBaVzUwSWl3aWMyVnlkbVZ5SWl3aWMyaGhjR1Z6SWl3aVptOXliV0YwSWl3aWNHbDJiM1FpWFN3aVpHVnRieUk2ZEhKMVpYMD0=');
// Set the extensions
jspreadsheet.setExtensions({ formula });
// Create a new spreadsheet
jspreadsheet(document.getElementById('spreadsheet'), {
worksheets: [{
data: [
[
"Sample A",
"Sample B",
"",
"Formula",
"Result"
],
[
2,
1,
"",
"ZTEST x=3",
"=ZTEST(A2:A6, 3)"
],
[
4,
3,
"",
"ZTEST x=6",
"=ZTEST(A2:A6, 6)"
],
[
6,
5,
"",
"ZTEST sigma=2",
"=ZTEST(A2:A6, 3, 2)"
],
[
8,
7,
"",
"AVERAGE A",
"=AVERAGE(A2:A6)"
],
[
10,
11
]
]
}]
});
</script>
</html>
import React, { useRef } from "react";
import { Spreadsheet, Worksheet, jspreadsheet } from "@jspreadsheet/react";
import formula from "@jspreadsheet/formula-pro";
import "jsuites/dist/jsuites.css";
import "jspreadsheet/dist/jspreadsheet.css";
// Set license
jspreadsheet.setLicense('NGZmMGY0MjA5NGEwZGVhMmU5MTA5MmQ0ZDE2MGFmNDRhYzBhMjBjYzAxMGZjMjIwY2NkNDE5MzVhZDI0ODc5NzFlNTNlNzYyZWI2NzdjMWFlMTBmZDk0MWUzZGE4NDk4YTZhMzliMzgyMTdjNmMxMTZmMjYzNWU3NzgyY2MxOTMsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpreE9EY3dPRGt3TENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0p6ZEdGamEySnNhWFI2TG1sdklpd2lkMlZpWTI5dWRHRnBibVZ5TG1sdklpd2liRzlqWVd4b2IzTjBJbDBzSW5Cc1lXNGlPaUl6TkNJc0luTmpiM0JsSWpwYkluWTNJaXdpZGpnaUxDSjJPU0lzSW5ZeE1DSXNJbll4TVNJc0luWXhNaUlzSW5ZeE15SXNJbU5vWVhKMGN5SXNJbVp2Y20xeklpd2labTl5YlhWc1lTSXNJbkJoY25ObGNpSXNJbkpsYm1SbGNpSXNJbU52YlcxbGJuUnpJaXdpYVcxd2IzSjBaWElpTENKaVlYSWlMQ0oyWVd4cFpHRjBhVzl1Y3lJc0luTmxZWEpqYUNJc0luQnlhVzUwSWl3aWMyaGxaWFJ6SWl3aVkyeHBaVzUwSWl3aWMyVnlkbVZ5SWl3aWMyaGhjR1Z6SWl3aVptOXliV0YwSWl3aWNHbDJiM1FpWFN3aVpHVnRieUk2ZEhKMVpYMD0=');
// Set the extensions
jspreadsheet.setExtensions({ formula });
export default function App() {
// Spreadsheet array of worksheets
const spreadsheet = useRef();
// Worksheet data
const data = [
[
"Sample A",
"Sample B",
"",
"Formula",
"Result"
],
[
2,
1,
"",
"ZTEST x=3",
"=ZTEST(A2:A6, 3)"
],
[
4,
3,
"",
"ZTEST x=6",
"=ZTEST(A2:A6, 6)"
],
[
6,
5,
"",
"ZTEST sigma=2",
"=ZTEST(A2:A6, 3, 2)"
],
[
8,
7,
"",
"AVERAGE A",
"=AVERAGE(A2:A6)"
],
[
10,
11
]
];
// Render component
return (
<Spreadsheet ref={spreadsheet}>
<Worksheet data={data} />
</Spreadsheet>
);
}
<template>
<Spreadsheet ref="spreadsheet">
<Worksheet :data="data" />
</Spreadsheet>
</template>
<script>
import { Spreadsheet, Worksheet, jspreadsheet } from "@jspreadsheet/vue";
import "jsuites/dist/jsuites.css";
import "jspreadsheet/dist/jspreadsheet.css";
import formula from "@jspreadsheet/formula-pro";
// Set license
jspreadsheet.setLicense('NGZmMGY0MjA5NGEwZGVhMmU5MTA5MmQ0ZDE2MGFmNDRhYzBhMjBjYzAxMGZjMjIwY2NkNDE5MzVhZDI0ODc5NzFlNTNlNzYyZWI2NzdjMWFlMTBmZDk0MWUzZGE4NDk4YTZhMzliMzgyMTdjNmMxMTZmMjYzNWU3NzgyY2MxOTMsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpreE9EY3dPRGt3TENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0p6ZEdGamEySnNhWFI2TG1sdklpd2lkMlZpWTI5dWRHRnBibVZ5TG1sdklpd2liRzlqWVd4b2IzTjBJbDBzSW5Cc1lXNGlPaUl6TkNJc0luTmpiM0JsSWpwYkluWTNJaXdpZGpnaUxDSjJPU0lzSW5ZeE1DSXNJbll4TVNJc0luWXhNaUlzSW5ZeE15SXNJbU5vWVhKMGN5SXNJbVp2Y20xeklpd2labTl5YlhWc1lTSXNJbkJoY25ObGNpSXNJbkpsYm1SbGNpSXNJbU52YlcxbGJuUnpJaXdpYVcxd2IzSjBaWElpTENKaVlYSWlMQ0oyWVd4cFpHRjBhVzl1Y3lJc0luTmxZWEpqYUNJc0luQnlhVzUwSWl3aWMyaGxaWFJ6SWl3aVkyeHBaVzUwSWl3aWMyVnlkbVZ5SWl3aWMyaGhjR1Z6SWl3aVptOXliV0YwSWl3aWNHbDJiM1FpWFN3aVpHVnRieUk2ZEhKMVpYMD0=');
// Set the extensions
jspreadsheet.setExtensions({ formula });
export default {
components: {
Spreadsheet,
Worksheet,
},
data() {
// Worksheet data
const data = [
[
"Sample A",
"Sample B",
"",
"Formula",
"Result"
],
[
2,
1,
"",
"ZTEST x=3",
"=ZTEST(A2:A6, 3)"
],
[
4,
3,
"",
"ZTEST x=6",
"=ZTEST(A2:A6, 6)"
],
[
6,
5,
"",
"ZTEST sigma=2",
"=ZTEST(A2:A6, 3, 2)"
],
[
8,
7,
"",
"AVERAGE A",
"=AVERAGE(A2:A6)"
],
[
10,
11
]
]
return {
data
};
}
}
</script>
import { Component, ViewChild, ElementRef } from "@angular/core";
import jspreadsheet from "jspreadsheet";
import formula from "@jspreadsheet/formula-pro";
// You can use the following license for quick testing on localhost, StackBlitz, or CodeSandbox.
// The license is valid for one day, after which the spreadsheet will become read-only.
// For a longer trial period, you can create a free account and generate a demo license with an extended expiration date.
jspreadsheet.setLicense('NGZmMGY0MjA5NGEwZGVhMmU5MTA5MmQ0ZDE2MGFmNDRhYzBhMjBjYzAxMGZjMjIwY2NkNDE5MzVhZDI0ODc5NzFlNTNlNzYyZWI2NzdjMWFlMTBmZDk0MWUzZGE4NDk4YTZhMzliMzgyMTdjNmMxMTZmMjYzNWU3NzgyY2MxOTMsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpreE9EY3dPRGt3TENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0p6ZEdGamEySnNhWFI2TG1sdklpd2lkMlZpWTI5dWRHRnBibVZ5TG1sdklpd2liRzlqWVd4b2IzTjBJbDBzSW5Cc1lXNGlPaUl6TkNJc0luTmpiM0JsSWpwYkluWTNJaXdpZGpnaUxDSjJPU0lzSW5ZeE1DSXNJbll4TVNJc0luWXhNaUlzSW5ZeE15SXNJbU5vWVhKMGN5SXNJbVp2Y20xeklpd2labTl5YlhWc1lTSXNJbkJoY25ObGNpSXNJbkpsYm1SbGNpSXNJbU52YlcxbGJuUnpJaXdpYVcxd2IzSjBaWElpTENKaVlYSWlMQ0oyWVd4cFpHRjBhVzl1Y3lJc0luTmxZWEpqYUNJc0luQnlhVzUwSWl3aWMyaGxaWFJ6SWl3aVkyeHBaVzUwSWl3aWMyVnlkbVZ5SWl3aWMyaGhjR1Z6SWl3aVptOXliV0YwSWl3aWNHbDJiM1FpWFN3aVpHVnRieUk2ZEhKMVpYMD0=');
// Set the extensions
jspreadsheet.setExtensions({ formula });
@Component({
standalone: true,
selector: "app-root",
template: `<div #spreadsheet></div>`
})
export class AppComponent {
@ViewChild("spreadsheet") spreadsheet: ElementRef;
// Worksheets
worksheets: jspreadsheet.worksheetInstance[];
// Create a new data grid
ngAfterViewInit() {
// Create spreadsheet
this.worksheets = jspreadsheet(this.spreadsheet.nativeElement, {
worksheets: [{
data: [
[
"Sample A",
"Sample B",
"",
"Formula",
"Result"
],
[
2,
1,
"",
"ZTEST x=3",
"=ZTEST(A2:A6, 3)"
],
[
4,
3,
"",
"ZTEST x=6",
"=ZTEST(A2:A6, 6)"
],
[
6,
5,
"",
"ZTEST sigma=2",
"=ZTEST(A2:A6, 3, 2)"
],
[
8,
7,
"",
"AVERAGE A",
"=AVERAGE(A2:A6)"
],
[
10,
11
]
]
}]
});
}
}