time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

README.md (2653B)


      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 # Quantile Function
     22 
     23 > Wilcoxon signed rank test statistic [quantile function][quantile-function].
     24 
     25 <section class="intro">
     26 
     27 </section>
     28 
     29 <!-- /.intro -->
     30 
     31 <section class="usage">
     32 
     33 ## Usage
     34 
     35 ```javascript
     36 var quantile = require( '@stdlib/stats/base/dists/signrank/quantile' );
     37 ```
     38 
     39 #### quantile( p, n )
     40 
     41 Evaluates the [quantile function][quantile-function] for the Wilcoxon signed rank test statistic with `n` observations.
     42 
     43 ```javascript
     44 var y = quantile( 0.8, 5 );
     45 // returns 11
     46 
     47 y = quantile( 0.5, 3 );
     48 // returns 3
     49 ```
     50 
     51 If provided a probability `p` outside the interval `[0,1]`, the function returns `NaN`.
     52 
     53 ```javascript
     54 var y = quantile( 1.9, 5 );
     55 // returns NaN
     56 
     57 y = quantile( -0.1, 5 );
     58 // returns NaN
     59 ```
     60 
     61 If provided `NaN` as any argument, the function returns `NaN`.
     62 
     63 ```javascript
     64 var y = quantile( NaN, 5 );
     65 // returns NaN
     66 
     67 y = quantile( 0.0, NaN);
     68 // returns NaN
     69 ```
     70 
     71 If not provided a positive integer for `n`, the function returns `NaN`.
     72 
     73 ```javascript
     74 var y = quantile( 0.4, -1.0 );
     75 // returns NaN
     76 
     77 y = quantile( 0.4, 3.7 );
     78 // returns NaN
     79 ```
     80 
     81 #### quantile.factory( n )
     82 
     83 Returns a function for evaluating the [quantile function][quantile-function] of the Wilcoxon signed rank test statistic with `n` observations.
     84 
     85 ```javascript
     86 var myQuantile = quantile.factory( 8 );
     87 
     88 var y = myQuantile( 0.4 );
     89 // returns 16
     90 
     91 y = myQuantile( 1.0 );
     92 // returns 36
     93 ```
     94 
     95 </section>
     96 
     97 <!-- /.usage -->
     98 
     99 <section class="examples">
    100 
    101 ## Examples
    102 
    103 <!-- eslint no-undef: "error" -->
    104 
    105 ```javascript
    106 var randint = require( '@stdlib/random/base/discrete-uniform' );
    107 var randu = require( '@stdlib/random/base/randu' );
    108 var quantile = require( '@stdlib/stats/base/dists/signrank/quantile' );
    109 
    110 var n;
    111 var p;
    112 var y;
    113 var i;
    114 
    115 for ( i = 0; i < 10; i++ ) {
    116     p = randu();
    117     n = randint( 1, 20 );
    118     y = quantile( p, n );
    119     console.log( 'p: %d, n: %d, Q(p;n): %d', p.toFixed( 4 ), n, y.toFixed( 4 ) );
    120 }
    121 ```
    122 
    123 </section>
    124 
    125 <!-- /.examples -->
    126 
    127 <section class="links">
    128 
    129 [quantile-function]: https://en.wikipedia.org/wiki/Quantile_function
    130 
    131 </section>
    132 
    133 <!-- /.links -->