|
| 1 | +<!-- |
| 2 | +
|
| 3 | +@license Apache-2.0 |
| 4 | +
|
| 5 | +Copyright (c) 2025 The Stdlib Authors. |
| 6 | +
|
| 7 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | +you may not use this file except in compliance with the License. |
| 9 | +You may obtain a copy of the License at |
| 10 | +
|
| 11 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | +
|
| 13 | +Unless required by applicable law or agreed to in writing, software |
| 14 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | +See the License for the specific language governing permissions and |
| 17 | +limitations under the License. |
| 18 | +
|
| 19 | +--> |
| 20 | + |
| 21 | +# Float64Results |
| 22 | + |
| 23 | +> Create a one-sample Z-test double-precision floating-point results object. |
| 24 | +
|
| 25 | +<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> |
| 26 | + |
| 27 | +<section class="intro"> |
| 28 | + |
| 29 | +</section> |
| 30 | + |
| 31 | +<!-- /.intro --> |
| 32 | + |
| 33 | +<!-- Package usage documentation. --> |
| 34 | + |
| 35 | +<section class="usage"> |
| 36 | + |
| 37 | +## Usage |
| 38 | + |
| 39 | +```javascript |
| 40 | +var Float64Results = require( '@stdlib/stats/base/ztest/one-sample/results/float64' ); |
| 41 | +``` |
| 42 | + |
| 43 | +#### Float64Results( \[arg\[, byteOffset\[, byteLength]]] ) |
| 44 | + |
| 45 | +Returns a one-sample Z-test double-precision floating-point results object. |
| 46 | + |
| 47 | +```javascript |
| 48 | +var results = new Float64Results(); |
| 49 | +// returns {...} |
| 50 | +``` |
| 51 | + |
| 52 | +The function supports the following parameters: |
| 53 | + |
| 54 | +- **arg**: an `ArrayBuffer` or a data object (_optional_). |
| 55 | +- **byteOffset**: byte offset (_optional_). |
| 56 | +- **byteLength**: maximum byte length (_optional_). |
| 57 | + |
| 58 | +A data object argument is an object having one or more of the following properties: |
| 59 | + |
| 60 | +- **rejected**: boolean indicating whether the null hypothesis was rejected. |
| 61 | +- **alternative**: the alternative hypothesis (e.g., `'two-sided'`, `'less'`, or `'greater'`). |
| 62 | +- **alpha**: significance level. |
| 63 | +- **pValue**: p-value. |
| 64 | +- **statistic**: test statistic. |
| 65 | +- **ci**: confidence interval as a `Float64Array`. |
| 66 | +- **nullValue**: mean under the null hypothesis. |
| 67 | +- **sd**: standard error of the mean. |
| 68 | + |
| 69 | +#### Float64Results.prototype.rejected |
| 70 | + |
| 71 | +Boolean indicating whether the null hypothesis was rejected. |
| 72 | + |
| 73 | +```javascript |
| 74 | +var results = new Float64Results(); |
| 75 | +// returns {...} |
| 76 | + |
| 77 | +// ... |
| 78 | + |
| 79 | +var v = results.rejected; |
| 80 | +// returns <boolean> |
| 81 | +``` |
| 82 | + |
| 83 | +#### Float64Results.prototype.alternative |
| 84 | + |
| 85 | +The alternative hypothesis. |
| 86 | + |
| 87 | +```javascript |
| 88 | +var results = new Float64Results(); |
| 89 | +// returns {...} |
| 90 | + |
| 91 | +// ... |
| 92 | + |
| 93 | +var v = results.alternative; |
| 94 | +// returns <string> |
| 95 | +``` |
| 96 | + |
| 97 | +#### Float64Results.prototype.alpha |
| 98 | + |
| 99 | +Significance level. |
| 100 | + |
| 101 | +```javascript |
| 102 | +var results = new Float64Results(); |
| 103 | +// returns {...} |
| 104 | + |
| 105 | +// ... |
| 106 | + |
| 107 | +var v = results.alpha; |
| 108 | +// returns <number> |
| 109 | +``` |
| 110 | + |
| 111 | +#### Float64Results.prototype.pValue |
| 112 | + |
| 113 | +The test p-value. |
| 114 | + |
| 115 | +```javascript |
| 116 | +var results = new Float64Results(); |
| 117 | +// returns {...} |
| 118 | + |
| 119 | +// ... |
| 120 | + |
| 121 | +var v = results.pValue; |
| 122 | +// returns <number> |
| 123 | +``` |
| 124 | + |
| 125 | +#### Float64Results.prototype.statistic |
| 126 | + |
| 127 | +The test statistic. |
| 128 | + |
| 129 | +```javascript |
| 130 | +var results = new Float64Results(); |
| 131 | +// returns {...} |
| 132 | + |
| 133 | +// ... |
| 134 | + |
| 135 | +var v = results.statistic; |
| 136 | +// returns <number> |
| 137 | +``` |
| 138 | + |
| 139 | +#### Float64Results.prototype.ci |
| 140 | + |
| 141 | +Confidence interval. |
| 142 | + |
| 143 | +```javascript |
| 144 | +var results = new Float64Results(); |
| 145 | +// returns {...} |
| 146 | + |
| 147 | +// ... |
| 148 | + |
| 149 | +var v = results.ci; |
| 150 | +// returns <Float64Array> |
| 151 | +``` |
| 152 | + |
| 153 | +#### Float64Results.prototype.nullValue |
| 154 | + |
| 155 | +Mean under the null hypothesis. |
| 156 | + |
| 157 | +```javascript |
| 158 | +var results = new Float64Results(); |
| 159 | +// returns {...} |
| 160 | + |
| 161 | +// ... |
| 162 | + |
| 163 | +var v = results.nullValue; |
| 164 | +// returns <number> |
| 165 | +``` |
| 166 | + |
| 167 | +#### Float64Results.prototype.sd |
| 168 | + |
| 169 | +Standard error of the mean. |
| 170 | + |
| 171 | +```javascript |
| 172 | +var results = new Float64Results(); |
| 173 | +// returns {...} |
| 174 | + |
| 175 | +// ... |
| 176 | + |
| 177 | +var v = results.sd; |
| 178 | +// returns <number> |
| 179 | +``` |
| 180 | + |
| 181 | +#### Float64Results.prototype.toString( \[options] ) |
| 182 | + |
| 183 | +Serializes a results object to a formatted string. |
| 184 | + |
| 185 | +```javascript |
| 186 | +var results = new Float64Results(); |
| 187 | +// returns {...} |
| 188 | + |
| 189 | +// ... |
| 190 | + |
| 191 | +var v = results.toString(); |
| 192 | +// returns <string> |
| 193 | +``` |
| 194 | + |
| 195 | +The method supports the following options: |
| 196 | + |
| 197 | +- **digits**: number of digits to display after decimal points. Default: `4`. |
| 198 | +- **decision**: boolean indicating whether to show the test decision. Default: `true`. |
| 199 | + |
| 200 | +Example output: |
| 201 | + |
| 202 | +```text |
| 203 | +
|
| 204 | +One-sample Z-test |
| 205 | +
|
| 206 | +Alternative hypothesis: True mean is less than 1.0 |
| 207 | +
|
| 208 | + pValue: 0.0406 |
| 209 | + statistic: 9.9901 |
| 210 | + 95% confidence interval: [9.7821, 10.4451] |
| 211 | +
|
| 212 | +Test Decision: Reject null in favor of alternative at 5% significance level |
| 213 | +
|
| 214 | +``` |
| 215 | + |
| 216 | +#### Float64Results.prototype.toJSON( \[options] ) |
| 217 | + |
| 218 | +Serializes a results object as a JSON object. |
| 219 | + |
| 220 | +```javascript |
| 221 | +var results = new Float64Results(); |
| 222 | +// returns {...} |
| 223 | + |
| 224 | +// ... |
| 225 | + |
| 226 | +var v = results.toJSON(); |
| 227 | +// returns {...} |
| 228 | +``` |
| 229 | + |
| 230 | +`JSON.stringify()` implicitly calls this method when stringifying a results instance. |
| 231 | + |
| 232 | +#### Float64Results.prototype.toDataView() |
| 233 | + |
| 234 | +Returns a [`DataView`][@stdlib/array/dataview] of a results object. |
| 235 | + |
| 236 | +```javascript |
| 237 | +var results = new Float64Results(); |
| 238 | +// returns {...} |
| 239 | + |
| 240 | +// ... |
| 241 | + |
| 242 | +var v = results.toDataView(); |
| 243 | +// returns <DataView> |
| 244 | +``` |
| 245 | + |
| 246 | +</section> |
| 247 | + |
| 248 | +<!-- /.usage --> |
| 249 | + |
| 250 | +<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 251 | + |
| 252 | +<section class="notes"> |
| 253 | + |
| 254 | +## Notes |
| 255 | + |
| 256 | +- A results object is a [`struct`][@stdlib/dstructs/struct] providing a fixed-width composite data structure for storing one-sample Z-test results and providing an ABI-stable data layout for JavaScript-C interoperation. |
| 257 | + |
| 258 | +</section> |
| 259 | + |
| 260 | +<!-- /.notes --> |
| 261 | + |
| 262 | +<!-- Package usage examples. --> |
| 263 | + |
| 264 | +<section class="examples"> |
| 265 | + |
| 266 | +## Examples |
| 267 | + |
| 268 | +<!-- eslint no-undef: "error" --> |
| 269 | + |
| 270 | +```javascript |
| 271 | +var Float64Array = require( '@stdlib/array/float64' ); |
| 272 | +var Results = require( '@stdlib/stats/base/ztest/one-sample/results/float64' ); |
| 273 | + |
| 274 | +var results = new Results({ |
| 275 | + 'rejected': true, |
| 276 | + 'alpha': 0.05, |
| 277 | + 'pValue': 0.3364, |
| 278 | + 'statistic': 11.7586, |
| 279 | + 'nullValue': 0.0, |
| 280 | + 'sd': 0.4563, |
| 281 | + 'ci': new Float64Array( [ 9.9983, 11.4123 ] ), |
| 282 | + 'alternative': 'two-sided' |
| 283 | +}); |
| 284 | + |
| 285 | +var str = results.toString({ |
| 286 | + 'format': 'linear' |
| 287 | +}); |
| 288 | +console.log( str ); |
| 289 | +``` |
| 290 | + |
| 291 | +</section> |
| 292 | + |
| 293 | +<!-- /.examples --> |
| 294 | + |
| 295 | +<!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 296 | + |
| 297 | +<section class="references"> |
| 298 | + |
| 299 | +</section> |
| 300 | + |
| 301 | +<!-- /.references --> |
| 302 | + |
| 303 | +<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> |
| 304 | + |
| 305 | +<section class="related"> |
| 306 | + |
| 307 | +</section> |
| 308 | + |
| 309 | +<!-- /.related --> |
| 310 | + |
| 311 | +<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 312 | + |
| 313 | +<section class="links"> |
| 314 | + |
| 315 | +[@stdlib/dstructs/struct]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/dstructs/struct |
| 316 | + |
| 317 | +[@stdlib/array/dataview]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/dataview |
| 318 | + |
| 319 | +</section> |
| 320 | + |
| 321 | +<!-- /.links --> |
0 commit comments