time-to-botec

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

README.md (2594B)


      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 # Probability Density Function
     22 
     23 > Wilcoxon signed rank test statistic [probability density function][pdf].
     24 
     25 <section class="intro">
     26 
     27 </section>
     28 
     29 <!-- /.intro -->
     30 
     31 <section class="usage">
     32 
     33 ## Usage
     34 
     35 ```javascript
     36 var pdf = require( '@stdlib/stats/base/dists/signrank/pdf' );
     37 ```
     38 
     39 #### pdf( x, n )
     40 
     41 Evaluates the [probability density function][pdf] of the Wilcoxon signed rank test statistic with `n` observations.
     42 
     43 ```javascript
     44 var y = pdf( 7.0, 9 );
     45 // returns ~0.0098
     46 
     47 y = pdf( 7.0, 6 );
     48 // returns ~0.063
     49 
     50 y = pdf( -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 = pdf( NaN, 8 );
     58 // returns NaN
     59 
     60 y = pdf( 0.0, NaN );
     61 // returns NaN
     62 ```
     63 
     64 If provided `x < 0`, the function returns `NaN`.
     65 
     66 ```javascript
     67 var y = pdf( 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 = pdf( 2.0, 0 );
     75 // returns NaN
     76 
     77 y = pdf( 2.0, -2 );
     78 // returns NaN
     79 
     80 y = pdf( 2.0, 8.9 );
     81 // returns NaN
     82 ```
     83 
     84 #### pdf.factory( n )
     85 
     86 Returns a function for evaluating the [probability density function][pdf] of the Wilcoxon signed rank test statistic with `n` observations.
     87 
     88 ```javascript
     89 var mypdf = pdf.factory( 8 );
     90 var y = mypdf( 4.0 );
     91 // returns ~0.008
     92 
     93 y = mypdf( 17.0 );
     94 // returns ~0.051
     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 pdf = require( '@stdlib/stats/base/dists/signrank/pdf' );
    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 = pdf( 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 [pdf]: https://en.wikipedia.org/wiki/Cumulative_distribution_function
    132 
    133 </section>
    134 
    135 <!-- /.links -->