time-to-botec

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

README.md (3744B)


      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 > [Normal][normal-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 [normal][normal-distribution] random variable with mean `μ` and standard deviation `σ > 0` is
     30 
     31 <!-- <equation class="equation" label="eq:normal_variance" align="center" raw="\operatorname{Var}\left[ X \right] = \sigma^2" alt="Variance for a normal distribution."> -->
     32 
     33 <div class="equation" align="center" data-raw-text="\operatorname{Var}\left[ X \right] = \sigma^2" data-equation="eq:normal_variance">
     34     <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@51534079fef45e990850102147e8945fb023d1d0/lib/node_modules/@stdlib/stats/base/dists/normal/variance/docs/img/equation_normal_variance.svg" alt="Variance for a normal 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 variance = require( '@stdlib/stats/base/dists/normal/variance' );
     52 ```
     53 
     54 #### variance( mu, sigma )
     55 
     56 Returns the [variance][variance] for a [normal][normal-distribution] distribution with parameters `mu` (mean) and `sigma` (standard deviation).
     57 
     58 ```javascript
     59 var y = variance( 2.0, 1.0 );
     60 // returns 1.0
     61 
     62 y = variance( -1.0, 4.0 );
     63 // returns 16.0
     64 ```
     65 
     66 If provided `NaN` as any argument, the function returns `NaN`.
     67 
     68 ```javascript
     69 var y = variance( NaN, 1.0 );
     70 // returns NaN
     71 
     72 y = variance( 0.0, NaN );
     73 // returns NaN
     74 ```
     75 
     76 If provided `sigma <= 0`, the function returns `NaN`.
     77 
     78 ```javascript
     79 var y = variance( 0.0, 0.0 );
     80 // returns NaN
     81 
     82 y = variance( 0.0, -1.0 );
     83 // returns NaN
     84 ```
     85 
     86 </section>
     87 
     88 <!-- /.usage -->
     89 
     90 <!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
     91 
     92 <section class="notes">
     93 
     94 </section>
     95 
     96 <!-- /.notes -->
     97 
     98 <!-- Package usage examples. -->
     99 
    100 <section class="examples">
    101 
    102 ## Examples
    103 
    104 <!-- eslint no-undef: "error" -->
    105 
    106 ```javascript
    107 var randu = require( '@stdlib/random/base/randu' );
    108 var variance = require( '@stdlib/stats/base/dists/normal/variance' );
    109 
    110 var sigma;
    111 var mu;
    112 var y;
    113 var i;
    114 
    115 for ( i = 0; i < 10; i++ ) {
    116     mu = ( randu()*10.0 ) - 5.0;
    117     sigma = randu() * 20.0;
    118     y = variance( mu, sigma );
    119     console.log( 'µ: %d, σ: %d, Var(X;µ,σ): %d', mu.toFixed( 4 ), sigma.toFixed( 4 ), y.toFixed( 4 ) );
    120 }
    121 ```
    122 
    123 </section>
    124 
    125 <!-- /.examples -->
    126 
    127 <!-- 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. -->
    128 
    129 <section class="references">
    130 
    131 </section>
    132 
    133 <!-- /.references -->
    134 
    135 <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
    136 
    137 <section class="links">
    138 
    139 [normal-distribution]: https://en.wikipedia.org/wiki/Normal_distribution
    140 
    141 [variance]: https://en.wikipedia.org/wiki/Variance
    142 
    143 </section>
    144 
    145 <!-- /.links -->