time-to-botec

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

README.md (3819B)


      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 # Moment-Generating Function
     22 
     23 > [Degenerate][degenerate] distribution moment-generating function (MGF).
     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 [moment-generating function][mgf] for a [degenerate][degenerate] random variable is
     30 
     31 <!-- <equation class="equation" label="eq:degenerate_mgf" align="center" raw="M_X(t) := e^{\mu t}" alt="Moment-generating function (MGF) of a degenerate distribution."> -->
     32 
     33 <div class="equation" align="center" data-raw-text="M_X(t) := e^{\mu t}" data-equation="eq:degenerate_mgf">
     34     <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@51534079fef45e990850102147e8945fb023d1d0/lib/node_modules/@stdlib/stats/base/dists/degenerate/mgf/docs/img/equation_degenerate_mgf.svg" alt="Moment-generating function (MGF) of a degenerate distribution.">
     35     <br>
     36 </div>
     37 
     38 <!-- </equation> -->
     39 
     40 where `mu` is the distribution mean.
     41 
     42 </section>
     43 
     44 <!-- /.intro -->
     45 
     46 <!-- Package usage documentation. -->
     47 
     48 <section class="usage">
     49 
     50 ## Usage
     51 
     52 ```javascript
     53 var mgf = require( '@stdlib/stats/base/dists/degenerate/mgf' );
     54 ```
     55 
     56 #### mgf( t, mu )
     57 
     58 Evaluates the moment-generating function ([MGF][mgf]) of a [degenerate][degenerate] distribution with parameter `mu` (mean).
     59 
     60 ```javascript
     61 var y = mgf( 1.0, 1.0 );
     62 // returns ~2.718
     63 
     64 y = mgf( 2.0, 3.0 );
     65 // returns ~403.429
     66 ```
     67 
     68 If provided `NaN` for any argument, the function returns `NaN`.
     69 
     70 ```javascript
     71 var y = mgf( NaN, 0.0 );
     72 // returns NaN
     73 
     74 y = mgf( 0.0, NaN );
     75 // returns NaN
     76 ```
     77 
     78 #### mgf.factory( mu )
     79 
     80 Returns a function for evaluating the [moment-generating function][mgf] of a [degenerate][degenerate] distribution with parameter `mu` (mean).
     81 
     82 ```javascript
     83 var mymgf = mgf.factory( 10.0 );
     84 
     85 var y = mymgf( 0.1 );
     86 // returns ~2.718
     87 ```
     88 
     89 </section>
     90 
     91 <!-- /.usage -->
     92 
     93 <!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
     94 
     95 <section class="notes">
     96 
     97 </section>
     98 
     99 <!-- /.notes -->
    100 
    101 <!-- Package usage examples. -->
    102 
    103 <section class="examples">
    104 
    105 ## Examples
    106 
    107 <!-- eslint no-undef: "error" -->
    108 
    109 ```javascript
    110 var randu = require( '@stdlib/random/base/randu' );
    111 var round = require( '@stdlib/math/base/special/round' );
    112 var mgf = require( '@stdlib/stats/base/dists/degenerate/mgf' );
    113 
    114 var mu;
    115 var t;
    116 var y;
    117 var i;
    118 
    119 for ( i = 0; i < 100; i++ ) {
    120     t = round( randu()*5.0 );
    121     mu = round( randu()*5.0 );
    122     y = mgf( t, mu );
    123     console.log( 'x: %d, µ: %d, M_X(t;µ): %d', t, mu, y );
    124 }
    125 ```
    126 
    127 </section>
    128 
    129 <!-- /.examples -->
    130 
    131 <!-- 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. -->
    132 
    133 <section class="references">
    134 
    135 </section>
    136 
    137 <!-- /.references -->
    138 
    139 <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
    140 
    141 <section class="links">
    142 
    143 [degenerate]: https://en.wikipedia.org/wiki/Degenerate_distribution
    144 
    145 [mgf]: https://en.wikipedia.org/wiki/Moment-generating_function
    146 
    147 </section>
    148 
    149 <!-- /.links -->