time-to-botec

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

README.md (2775B)


      1 <!--
      2 
      3 @license Apache-2.0
      4 
      5 Copyright (c) 2018 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 # betainc
     22 
     23 > [Incomplete beta function][incomplete-beta-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 betainc = require( '@stdlib/math/base/special/betainc' );
     37 ```
     38 
     39 #### betainc( x, a, b\[, regularized\[, upper]] )
     40 
     41 By default, evaluates the regularized lower [incomplete beta function][incomplete-beta-function] for inputs `x`, `a > 0` and `b > 0`. The fourth and fifth parameters of the function can be used to specify whether instead to evaluate the non-regularized and/or upper incomplete beta functions, respectively.
     42 
     43 ```javascript
     44 var y = betainc( 0.5, 2.0, 2.0 );
     45 // returns 0.5
     46 
     47 y = betainc( 0.5, 2.0, 2.0, false );
     48 // returns ~0.083
     49 
     50 y = betainc( 0.2, 1.0, 2.0 );
     51 // returns 0.36
     52 
     53 y = betainc( 0.2, 1.0, 2.0, true, true );
     54 // returns 0.64
     55 ```
     56 
     57 If provided `NaN` as any argument, the function returns `NaN`.
     58 
     59 ```javascript
     60 var y = betainc( NaN, 1.0, 1.0 );
     61 // returns NaN
     62 
     63 y = betainc( 0.8, NaN, 1.0 );
     64 // returns NaN
     65 
     66 y = betainc( 0.8, 1.0, NaN );
     67 // returns NaN
     68 ```
     69 
     70 If provided a `x` outside the interval `[0,1]`, the function returns `NaN`.
     71 
     72 ```javascript
     73 var y = betainc( 1.5, 1.0, 1.0 );
     74 // returns NaN
     75 
     76 y = betainc( -0.5, 1.0, 1.0 );
     77 // returns NaN
     78 ```
     79 
     80 If provided a negative `a`, the function returns `NaN`.
     81 
     82 ```javascript
     83 var y = betainc( 0.5, -2.0, 2.0 );
     84 // returns NaN
     85 ```
     86 
     87 If provided a negative `b`, the function returns `NaN`.
     88 
     89 ```javascript
     90 var y = betainc( 0.5, 2.0, -2.0 );
     91 // returns NaN
     92 ```
     93 
     94 </section>
     95 
     96 <!-- /.usage -->
     97 
     98 <section class="examples">
     99 
    100 ## Examples
    101 
    102 <!-- eslint no-undef: "error" -->
    103 
    104 ```javascript
    105 var randu = require( '@stdlib/random/base/randu' );
    106 var betainc = require( '@stdlib/math/base/special/betainc' );
    107 
    108 var i;
    109 var x;
    110 var a;
    111 var b;
    112 
    113 for ( i = 0; i < 100; i++ ) {
    114     x = randu();
    115     a = randu() * 10.0;
    116     b = randu() * 10.0;
    117     console.log( 'x: %d, \t a: %d, \t b: %d, \t f(x,a,b): %d', x.toFixed( 4 ), a.toFixed( 4 ), b.toFixed( 4 ), betainc( x, a, b ).toFixed( 4 ) );
    118 }
    119 ```
    120 
    121 </section>
    122 
    123 <!-- /.examples -->
    124 
    125 <section class="links">
    126 
    127 [incomplete-beta-function]: https://en.wikipedia.org/wiki/Incomplete_beta_function
    128 
    129 </section>
    130 
    131 <!-- /.links -->