time-to-botec

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

README.md (3876B)


      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 # Variance
     22 
     23 > [Student's t][t-distribution] distribution [variance][variance].
     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 [variance][variance] for a [Student's t][t-distribution] random variable with degrees of freedom `ν` is
     30 
     31 <!-- <equation class="equation" label="eq:t_variance" align="center" raw="\operatorname{Var}\left( X \right) = \begin{cases} \frac{\nu }{\nu-2} & \text{ for } \nu > 2 \\ \infty & \text{ for } 1 < \nu \le 2 \end{cases}" alt="Variance for a Student's t distribution."> -->
     32 
     33 <div class="equation" align="center" data-raw-text="\operatorname{Var}\left( X \right) = \begin{cases} \frac{\nu }{\nu-2} &amp; \text{ for } \nu &gt; 2 \\ \infty &amp; \text{ for } 1 &lt; \nu \le 2 \end{cases}" data-equation="eq:t_variance">
     34     <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@51534079fef45e990850102147e8945fb023d1d0/lib/node_modules/@stdlib/stats/base/dists/t/variance/docs/img/equation_t_variance.svg" alt="Variance for a Student's t distribution.">
     35     <br>
     36 </div>
     37 
     38 <!-- </equation> -->
     39 
     40 For `ν` smaller than one, the variance is not defined.
     41 
     42 </section>
     43 
     44 <!-- /.intro -->
     45 
     46 <!-- Package usage documentation. -->
     47 
     48 <section class="usage">
     49 
     50 ## Usage
     51 
     52 ```javascript
     53 var variance = require( '@stdlib/stats/base/dists/t/variance' );
     54 ```
     55 
     56 #### variance( v )
     57 
     58 Returns the [variance][variance] of a [Student's t][t-distribution] distribution with degrees of freedom `v`.
     59 
     60 ```javascript
     61 var y = variance( 9.0 );
     62 // returns ~1.286
     63 
     64 y = variance( 3.5 );
     65 // returns ~2.333
     66 ```
     67 
     68 If provided `1 < v <= 2`, the function returns `infinity`.
     69 
     70 ```javascript
     71 var y = variance( 1.5 );
     72 // returns Infinity
     73 
     74 y = variance( 2.0 );
     75 // returns Infinity
     76 ```
     77 
     78 If provided `v <= 1`, the function returns `NaN`.
     79 
     80 ```javascript
     81 var y = variance( -1.0 );
     82 // returns NaN
     83 
     84 y = variance( 0.8 );
     85 // returns NaN
     86 ```
     87 
     88 </section>
     89 
     90 <!-- /.usage -->
     91 
     92 <!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
     93 
     94 <section class="notes">
     95 
     96 </section>
     97 
     98 <!-- /.notes -->
     99 
    100 <!-- Package usage examples. -->
    101 
    102 <section class="examples">
    103 
    104 ## Examples
    105 
    106 <!-- eslint no-undef: "error" -->
    107 
    108 ```javascript
    109 var randu = require( '@stdlib/random/base/randu' );
    110 var round = require( '@stdlib/math/base/special/round' );
    111 var variance = require( '@stdlib/stats/base/dists/t/variance' );
    112 
    113 var v;
    114 var y;
    115 var i;
    116 
    117 for ( i = 0; i < 10; i++ ) {
    118     v = randu() * 20.0;
    119     y = variance( v );
    120     console.log( 'v: %d, Var(X,v): %d', v.toFixed( 4 ), y.toFixed( 4 ) );
    121 }
    122 ```
    123 
    124 </section>
    125 
    126 <!-- /.examples -->
    127 
    128 <!-- 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. -->
    129 
    130 <section class="references">
    131 
    132 </section>
    133 
    134 <!-- /.references -->
    135 
    136 <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
    137 
    138 <section class="links">
    139 
    140 [t-distribution]: https://en.wikipedia.org/wiki/Student%27s_t-distribution
    141 
    142 [variance]: https://en.wikipedia.org/wiki/Variance
    143 
    144 </section>
    145 
    146 <!-- /.links -->