You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lib/node_modules/@stdlib/stats/ztest/README.md
+26-51Lines changed: 26 additions & 51 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,24 +35,18 @@ var ztest = require( '@stdlib/stats/ztest' );
35
35
The function performs a one-sample z-test for the null hypothesis that the data in [array][mdn-array] or [typed array][mdn-typed-array]`x` is drawn from a normal distribution with mean zero and known standard deviation `sigma`.
36
36
37
37
```javascript
38
-
var normal =require( '@stdlib/random/base/normal' ).factory;
38
+
var normal =require( '@stdlib/random/array/normal' );
39
39
40
-
var rnorm =normal( 0.0, 2.0, {
41
-
'seed':5776
42
-
});
43
-
44
-
var arr =newArray( 300 );
45
-
var i;
46
-
for ( i =0; i <arr.length; i++ ) {
47
-
arr[ i ] =rnorm();
48
-
}
40
+
// Create an array of random numbers:
41
+
var arr =normal( 300, 0.0, 2.0 );
49
42
43
+
// Test whether true mean is equal to 0.0:
50
44
var out =ztest( arr, 2.0 );
51
45
/* e.g., returns
52
46
{
53
47
'rejected': false,
54
48
'pValue': ~0.155,
55
-
'statistic': -1.422,
49
+
'statistic': ~-1.422,
56
50
'ci': [~-0.391,~0.062],
57
51
// ...
58
52
}
@@ -90,16 +84,13 @@ The `ztest` function accepts the following `options`:
90
84
By default, the hypothesis test is carried out at a significance level of `0.05`. To choose a different significance level, set the `alpha` option.
91
85
92
86
```javascript
93
-
var table;
94
-
var out;
95
-
var arr;
87
+
var arr = [ 2, 4, 3, 1, 0 ];
96
88
97
-
arr = [ 2, 4, 3, 1, 0 ];
98
-
99
-
out =ztest( arr, 2.0, {
89
+
var out =ztest( arr, 2.0, {
100
90
'alpha':0.01
101
91
});
102
-
table =out.print();
92
+
93
+
var table =out.print();
103
94
/* e.g., returns
104
95
One-sample z-test
105
96
@@ -132,19 +123,16 @@ table = out.print();
132
123
To test whether the data comes from a distribution with a mean different than zero, set the `mu` option.
133
124
134
125
```javascript
135
-
var out;
136
-
var arr;
137
-
138
-
arr = [ 4, 4, 6, 6, 5 ];
126
+
var arr = [ 4, 4, 6, 6, 5 ];
139
127
140
-
out =ztest( arr, 1.0, {
128
+
varout =ztest( arr, 1.0, {
141
129
'mu':5.0
142
130
});
143
131
/* e.g., returns
144
132
{
145
133
'rejected': false,
146
-
'pValue': 1,
147
-
'statistic': 0,
134
+
'pValue': 1.0,
135
+
'statistic': 0.0,
148
136
'ci': [ ~4.123, ~5.877 ],
149
137
// ...
150
138
}
@@ -154,22 +142,19 @@ out = ztest( arr, 1.0, {
154
142
By default, a two-sided test is performed. To perform either of the one-sided tests, set the `alternative` option to `less` or `greater`.
155
143
156
144
```javascript
157
-
var table;
158
-
var out;
159
-
var arr;
160
-
161
-
arr = [ 4, 4, 6, 6, 5 ];
145
+
var arr = [ 4, 4, 6, 6, 5 ];
162
146
163
-
out =ztest( arr, 1.0, {
147
+
varout =ztest( arr, 1.0, {
164
148
'alternative':'less'
165
149
});
166
-
table =out.print();
150
+
151
+
var table =out.print();
167
152
/* e.g., returns
168
153
One-sample z-test
169
154
170
155
Alternative hypothesis: True mean is less than 0
171
156
172
-
pValue: 1
157
+
pValue: 1.0
173
158
statistic: 11.1803
174
159
95% confidence interval: [-Infinity,5.7356]
175
160
@@ -185,7 +170,7 @@ table = out.print();
185
170
186
171
Alternative hypothesis: True mean is greater than 0
187
172
188
-
pValue: 0
173
+
pValue: 0.0
189
174
statistic: 11.1803
190
175
95% confidence interval: [4.2644,Infinity]
191
176
@@ -204,38 +189,28 @@ table = out.print();
204
189
<!-- eslint no-undef: "error" -->
205
190
206
191
```javascript
207
-
var normal =require( '@stdlib/random/base/normal' ).factory;
192
+
var normal =require( '@stdlib/random/array/normal' );
208
193
var ztest =require( '@stdlib/stats/ztest' );
209
194
210
-
var rnorm;
211
-
var arr;
212
-
var out;
213
-
var i;
214
-
215
-
rnorm =normal( 5.0, 4.0, {
216
-
'seed':37827
217
-
});
218
-
arr =newArray( 500 );
219
-
for ( i =0; i <arr.length; i++ ) {
220
-
arr[ i ] =rnorm();
221
-
}
195
+
// Create an array of random numbers:
196
+
var arr =normal( 500, 5.0, 4.0 );
222
197
223
-
// Test whether true mean is equal to zero:
224
-
out =ztest( arr, 4.0 );
198
+
// Test whether true mean is equal to 0.0:
199
+
varout =ztest( arr, 4.0 );
225
200
console.log( out.print() );
226
201
/* e.g., =>
227
202
One-sample z-test
228
203
229
204
Alternative hypothesis: True mean is not equal to 0
230
205
231
-
pValue: 0
206
+
pValue: 0.0
232
207
statistic: 28.6754
233
208
95% confidence interval: [4.779,5.4802]
234
209
235
210
Test Decision: Reject null in favor of alternative at 5% significance level
0 commit comments