time-to-botec

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

README.md (3998B)


      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 # Mean
     22 
     23 > [F][f-distribution] distribution [expected value][expected-value].
     24 
     25 <!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
     26 
     27 <section class="intro">
     28 
     29 The [expected value][expected-value] for a [F][f-distribution] random variable with numerator degrees of freedom `d1 > 0` and denominator degrees of freedom `d2 > 0` is defined as
     30 
     31 <!-- <equation class="equation" label="eq:f_expectation" align="center" raw="\mathbb{E}\left[ X \right] = \frac{d_2}{d_2-2}" alt="Expected value for an F distribution."> -->
     32 
     33 <div class="equation" align="center" data-raw-text="\mathbb{E}\left[ X \right] = \frac{d_2}{d_2-2}" data-equation="eq:f_expectation">
     34     <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@51534079fef45e990850102147e8945fb023d1d0/lib/node_modules/@stdlib/stats/base/dists/f/mean/docs/img/equation_f_expectation.svg" alt="Expected value for an F distribution.">
     35     <br>
     36 </div>
     37 
     38 <!-- </equation> -->
     39 
     40 </section>
     41 
     42 <!-- /.intro -->
     43 
     44 <!-- Package usage documentation. -->
     45 
     46 <section class="usage">
     47 
     48 ## Usage
     49 
     50 ```javascript
     51 var mean = require( '@stdlib/stats/base/dists/f/mean' );
     52 ```
     53 
     54 #### mean( d1, d2 )
     55 
     56 Returns the [expected value][expected-value] of a [F][f-distribution] distribution with parameters `d1` (numerator degrees of freedom) and `d2` (denominator degrees of freedom).
     57 
     58 ```javascript
     59 var v = mean( 4.0, 5.0 );
     60 // returns ~1.667
     61 
     62 v = mean( 4.0, 12.0 );
     63 // returns ~1.2
     64 
     65 v = mean( 8.0, 4.0 );
     66 // returns 2.0
     67 ```
     68 
     69 If provided `NaN` as any argument, the function returns `NaN`.
     70 
     71 ```javascript
     72 var v = mean( NaN, 3.0 );
     73 // returns NaN
     74 
     75 v = mean( 3.0, NaN );
     76 // returns NaN
     77 ```
     78 
     79 If provided `d1 <= 0`, the function returns `NaN`.
     80 
     81 ```javascript
     82 var v = mean( 0.0, 3.0 );
     83 // returns NaN
     84 
     85 v = mean( -1.0, 3.0 );
     86 // returns NaN
     87 ```
     88 
     89 If provided `d2 <= 2`, the function returns `NaN`.
     90 
     91 ```javascript
     92 var v = mean( 2.0, 1.8 );
     93 // returns NaN
     94 
     95 v = mean( 1.0, -1.0 );
     96 // returns NaN
     97 ```
     98 
     99 </section>
    100 
    101 <!-- /.usage -->
    102 
    103 <!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
    104 
    105 <section class="notes">
    106 
    107 </section>
    108 
    109 <!-- /.notes -->
    110 
    111 <!-- Package usage examples. -->
    112 
    113 <section class="examples">
    114 
    115 ## Examples
    116 
    117 <!-- eslint no-undef: "error" -->
    118 
    119 ```javascript
    120 var randu = require( '@stdlib/random/base/randu' );
    121 var EPS = require( '@stdlib/constants/float64/eps' );
    122 var mean = require( '@stdlib/stats/base/dists/f/mean' );
    123 
    124 var d1;
    125 var d2;
    126 var v;
    127 var i;
    128 
    129 for ( i = 0; i < 10; i++ ) {
    130     d1 = ( randu()*10.0 ) + EPS;
    131     d2 = ( randu()*10.0 ) + EPS;
    132     v = mean( d1, d2 );
    133     console.log( 'd1: %d, d2: %d, E(X;d1,d2): %d', d1.toFixed( 4 ), d2.toFixed( 4 ), v.toFixed( 4 ) );
    134 }
    135 ```
    136 
    137 </section>
    138 
    139 <!-- /.examples -->
    140 
    141 <!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
    142 
    143 <section class="references">
    144 
    145 </section>
    146 
    147 <!-- /.references -->
    148 
    149 <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
    150 
    151 <section class="links">
    152 
    153 [f-distribution]: https://en.wikipedia.org/wiki/F_distribution
    154 
    155 [expected-value]: https://en.wikipedia.org/wiki/Expected_value
    156 
    157 </section>
    158 
    159 <!-- /.links -->