time-to-botec

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

README.md (3951B)


      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 # Entropy
     22 
     23 > [Cauchy][cauchy-distribution] distribution [differential entropy][entropy].
     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 [differential entropy][entropy] for a [Cauchy][cauchy-distribution] random variable with location parameter `x0` and scale parameter `Ɣ > 0` is
     30 
     31 <!-- <equation class="equation" label="eq:cauchy_entropy" align="center" raw="h\left( X \right) = \log(\gamma)\,+\,\log(4\,\pi)" alt="Differential entropy for a Cauchy distribution."> -->
     32 
     33 <div class="equation" align="center" data-raw-text="h\left( X \right) = \log(\gamma)\,+\,\log(4\,\pi)" data-equation="eq:cauchy_entropy">
     34     <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@51534079fef45e990850102147e8945fb023d1d0/lib/node_modules/@stdlib/stats/base/dists/cauchy/entropy/docs/img/equation_cauchy_entropy.svg" alt="Differential entropy for a Cauchy 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 entropy = require( '@stdlib/stats/base/dists/cauchy/entropy' );
     52 ```
     53 
     54 #### entropy( x0, gamma )
     55 
     56 Returns the [differential entropy][entropy] of a [Cauchy][cauchy-distribution] distribution with location parameter `x0` and scale parameter `gamma` (in [nats][nats]).
     57 
     58 ```javascript
     59 var v = entropy( 10.0, 5.0 );
     60 // returns ~4.14
     61 
     62 v = entropy( 7.0, 2.0 );
     63 // returns ~3.224
     64 ```
     65 
     66 If provided `NaN` as any argument, the function returns `NaN`.
     67 
     68 ```javascript
     69 var v = entropy( NaN, 5.0 );
     70 // returns NaN
     71 
     72 v = entropy( 20.0, NaN );
     73 // returns NaN
     74 ```
     75 
     76 If provided `gamma <= 0`, the function returns `NaN`.
     77 
     78 ```javascript
     79 var v = entropy( 1.0, -1.0 );
     80 // returns NaN
     81 
     82 v = entropy( 1.0, 0.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 EPS = require( '@stdlib/constants/float64/eps' );
    109 var entropy = require( '@stdlib/stats/base/dists/cauchy/entropy' );
    110 
    111 var gamma;
    112 var x0;
    113 var v;
    114 var i;
    115 
    116 for ( i = 0; i < 10; i++ ) {
    117     x0 = randu() * 100.0;
    118     gamma = ( randu()*10.0 ) + EPS;
    119     v = entropy( x0, gamma );
    120     console.log( 'x0: %d, γ: %d, h(X;x0,γ): %d', x0.toFixed( 4 ), gamma.toFixed( 4 ), v.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 [cauchy-distribution]: https://en.wikipedia.org/wiki/Cauchy_distribution
    141 
    142 [entropy]: https://en.wikipedia.org/wiki/Entropy_%28information_theory%29
    143 
    144 [nats]: https://en.wikipedia.org/wiki/Nat_%28unit%29
    145 
    146 </section>
    147 
    148 <!-- /.links -->