README.md (2609B)
1 <!-- 2 3 @license Apache-2.0 4 5 Copyright (c) 2020 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 # Cumulative Distribution Function 22 23 > Wilcoxon signed rank test statistic [cumulative distribution function][cdf]. 24 25 <section class="intro"> 26 27 </section> 28 29 <!-- /.intro --> 30 31 <section class="usage"> 32 33 ## Usage 34 35 ```javascript 36 var cdf = require( '@stdlib/stats/base/dists/signrank/cdf' ); 37 ``` 38 39 #### cdf( x, n ) 40 41 Evaluates the [cumulative distribution function][cdf] of the Wilcoxon signed rank test statistic with `n` observations. 42 43 ```javascript 44 var y = cdf( 7.0, 9 ); 45 // returns ~0.037 46 47 y = cdf( 7.0, 6 ); 48 // returns ~0.281 49 50 y = cdf( -1.0, 40 ); 51 // returns 0.0 52 ``` 53 54 If provided `NaN` as any argument, the function returns `NaN`. 55 56 ```javascript 57 var y = cdf( NaN, 8 ); 58 // returns NaN 59 60 y = cdf( 0.0, NaN ); 61 // returns NaN 62 ``` 63 64 If provided `x < 0`, the function returns `NaN`. 65 66 ```javascript 67 var y = cdf( 2.0, -1.0 ); 68 // returns NaN 69 ``` 70 71 If not provided a positive integer for `n`, the function returns `NaN`. 72 73 ```javascript 74 var y = cdf( 2.0, 0 ); 75 // returns NaN 76 77 y = cdf( 2.0, -2 ); 78 // returns NaN 79 80 y = cdf( 2.0, 8.9 ); 81 // returns NaN 82 ``` 83 84 #### cdf.factory( n ) 85 86 Returns a function for evaluating the [cumulative distribution function][cdf] of the Wilcoxon signed rank test statistic with `n` observations. 87 88 ```javascript 89 var mycdf = cdf.factory( 8 ); 90 var y = mycdf( 3.9 ); 91 // returns ~0.027 92 93 y = mycdf( 17.0 ); 94 // returns ~0.473 95 ``` 96 97 </section> 98 99 <!-- /.usage --> 100 101 <section class="examples"> 102 103 ## Examples 104 105 <!-- eslint no-undef: "error" --> 106 107 ```javascript 108 var ceil = require( '@stdlib/math/base/special/ceil' ); 109 var randu = require( '@stdlib/random/base/randu' ); 110 var cdf = require( '@stdlib/stats/base/dists/signrank/cdf' ); 111 112 var n; 113 var x; 114 var y; 115 var i; 116 117 for ( i = 0; i < 10; i++ ) { 118 x = randu() * 30.0; 119 n = ceil( randu() * 30.0 ); 120 y = cdf( x, n ); 121 console.log( 'x: %d, n: %d, F(x;n): %d', x.toFixed( 4 ), n.toFixed( 4 ), y.toFixed( 4 ) ); 122 } 123 ``` 124 125 </section> 126 127 <!-- /.examples --> 128 129 <section class="links"> 130 131 [cdf]: https://en.wikipedia.org/wiki/Cumulative_distribution_function 132 133 </section> 134 135 <!-- /.links -->