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