time-to-botec

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

README.md (4077B)


      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 # erfinv
     22 
     23 > [Inverse error function][inverse-error-function].
     24 
     25 <section class="intro">
     26 
     27 The [inverse error function][inverse-error-function] is defined in terms of the [Maclaurin series][maclaurin-series]
     28 
     29 <!-- <equation class="equation" label="eq:inverse_error_function" align="center" raw="\operatorname{erf}^{-1}(z)=\sum_{k=0}^\infty\frac{c_k}{2k+1}\left (\frac{\sqrt{\pi}}{2}z\right )^{2k+1}" alt="Inverse error function."> -->
     30 
     31 <div class="equation" align="center" data-raw-text="\operatorname{erf}^{-1}(z)=\sum_{k=0}^\infty\frac{c_k}{2k+1}\left (\frac{\sqrt{\pi}}{2}z\right )^{2k+1}" data-equation="eq:inverse_error_function">
     32     <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@591cf9d5c3a0cd3c1ceec961e5c49d73a68374cb/lib/node_modules/@stdlib/math/base/special/erfinv/docs/img/equation_inverse_error_function.svg" alt="Inverse error function.">
     33     <br>
     34 </div>
     35 
     36 <!-- </equation> -->
     37 
     38 where `c_0 = 1` and 
     39 
     40 <!-- <equation class="equation" label="eq:inverse_error_function_series_coefficients" align="center" raw="c_k=\sum_{m=0}^{k-1}\frac{c_m c_{k-1-m}}{(m+1)(2m+1)} = \left\{1,1,\frac{7}{6},\frac{127}{90},\frac{4369}{2520},\frac{34807}{16200},\ldots\right\}" alt="Series coefficients."> -->
     41 
     42 <div class="equation" align="center" data-raw-text="c_k=\sum_{m=0}^{k-1}\frac{c_m c_{k-1-m}}{(m+1)(2m+1)} = \left\{1,1,\frac{7}{6},\frac{127}{90},\frac{4369}{2520},\frac{34807}{16200},\ldots\right\}" data-equation="eq:inverse_error_function_series_coefficients">
     43     <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@591cf9d5c3a0cd3c1ceec961e5c49d73a68374cb/lib/node_modules/@stdlib/math/base/special/erfinv/docs/img/equation_inverse_error_function_series_coefficients.svg" alt="Series coefficients.">
     44     <br>
     45 </div>
     46 
     47 <!-- </equation> -->
     48 
     49 </section>
     50 
     51 <!-- /.intro -->
     52 
     53 <section class="usage">
     54 
     55 ## Usage
     56 
     57 ```javascript
     58 var erfinv = require( '@stdlib/math/base/special/erfinv' );
     59 ```
     60 
     61 #### erfinv( x )
     62 
     63 Evaluates the [inverse error function][inverse-error-function].
     64 
     65 ```javascript
     66 var y = erfinv( 0.5 );
     67 // returns ~0.4769
     68 
     69 y = erfinv( 0.8 );
     70 // returns ~0.9062
     71 
     72 y = erfinv( -1.0 );
     73 // returns -Infinity
     74 
     75 y = erfinv( 1.0 );
     76 // returns Infinity
     77 ```
     78 
     79 The domain of `x` is restricted to `[-1,1]`. If `|x| > 1`, the function returns `NaN`.
     80 
     81 ```javascript
     82 var y = erfinv( -3.14 );
     83 // returns NaN
     84 ```
     85 
     86 If provided `NaN`, the function returns `NaN`.
     87 
     88 ```javascript
     89 var y = erfinv( NaN );
     90 // returns NaN
     91 ```
     92 
     93 The [inverse error function][inverse-error-function] is an [odd function][odd-function]; i.e., `erfinv(-x) = -erfinv(x)`. Thus, in accordance with the [IEEE 754][ieee754] standard, if provided `-0`, the function returns `-0`.
     94 
     95 ```javascript
     96 var y = erfinv( -0.0 );
     97 // returns -0.0
     98 ```
     99 
    100 </section>
    101 
    102 <!-- /.usage -->
    103 
    104 <section class="examples">
    105 
    106 ## Examples
    107 
    108 <!-- eslint no-undef: "error" -->
    109 
    110 ```javascript
    111 var linspace = require( '@stdlib/array/linspace' );
    112 var erfinv = require( '@stdlib/math/base/special/erfinv' );
    113 
    114 var x = linspace( -1.0, 1.0, 100 );
    115 var y;
    116 var i;
    117 
    118 for ( i = 0; i < x.length; i++ ) {
    119     y = erfinv( x[ i ] );
    120     console.log( 'x: %d, erfinv(x): %d', x[ i ], y );
    121 }
    122 ```
    123 
    124 </section>
    125 
    126 <!-- /.examples -->
    127 
    128 <section class="links">
    129 
    130 [inverse-error-function]: https://en.wikipedia.org/wiki/Error_function#Inverse_functions
    131 
    132 [maclaurin-series]: http://mathworld.wolfram.com/MaclaurinSeries.html
    133 
    134 [odd-function]: https://en.wikipedia.org/wiki/Even_and_odd_functions
    135 
    136 [ieee754]: https://en.wikipedia.org/wiki/IEEE_754-1985
    137 
    138 </section>
    139 
    140 <!-- /.links -->